Skip to content

Instantly share code, notes, and snippets.

View dylanchapell's full-sized avatar
📚

Dylan Chapell dylanchapell

📚
  • Colorado Springs, Colorado
View GitHub Profile
@dylanchapell
dylanchapell / malloc0.c
Created December 16, 2023 20:27
What happens on malloc0? Does it return NULL or a valid pointer? Depends on the system. If it returns NULL, this program segfaults on the assert.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int main() {
void* myemptyptr = malloc(0);
void* myfullptr = malloc(10);
assert(myemptyptr);
printf("Empty pointer: %p 10byte Pointer: %p\n", myemptyptr, myfullptr);
free(myemptyptr);

Keybase proof

I hereby claim:

  • I am dylanchapell on github.
  • I am dylanchapell1 (https://keybase.io/dylanchapell1) on keybase.
  • I have a public key ASD5tlwPWUDozxtQFOKVbtR8AzdoS1H4fIKwWPYiaWDGdQo

To claim this, I am signing this object:

@dylanchapell
dylanchapell / decode.py
Created November 10, 2022 21:27
Decode number codes to letters using encoding from A Friendly Introduction to Number Theory textbook, with a=11 and z=36
import sys
letterdict = {
11:'a',
12:'b',
13:'c',
14:'d',
15:'e',
16:'f',
17:'g',
@dylanchapell
dylanchapell / euclidian.py
Created November 1, 2022 18:13
Quick python program to calculate the greatest common divisor of two numbers using the euclidian algorithm and print out steps
import math
print("We will compute gcd(a,b)")
firstA = int(input("Enter A: "))
firstB = int(input("Enter B: "))
A = firstA
B = firstB
lastR = 1
R = 1