Skip to content

Instantly share code, notes, and snippets.

@reagent
reagent / dynamic.c
Created February 6, 2013 18:44
Dynamic header structs
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct Header {
char *key;
char *value;
} Header;
typedef struct Response {
@reagent
reagent / .gitignore
Last active December 13, 2015 22:59
Just puttin' it out there
main
*.dSYM
main
*.dSYM
@reagent
reagent / .gitignore
Last active December 14, 2015 00:59
File parsing w/ linked list / array
array
list
*.o
*.dSYM
@reagent
reagent / .gitignore
Created March 18, 2013 17:45
Dynamic Array
*.o
main
*.dSYM
@reagent
reagent / .gitignore
Last active December 15, 2015 07:18
Dynamic array + union
main
*.o
*.dSYM
@reagent
reagent / malloc_size.c
Created March 25, 2013 19:49
Checking size of allocation
#include <stdlib.h>
#include <stdio.h>
#include <malloc/malloc.h>
int
main()
{
char *thing = malloc(1 * sizeof(char));
printf("Alloc'd: %ld bytes\n", malloc_size(thing));
@reagent
reagent / .gitignore
Created April 1, 2013 14:50
String Calculator
calc
*.o
*.dSYM
@reagent
reagent / .gitignore
Created April 1, 2013 14:51
Implementation of realloc / malloc
realloc
*.o
*.dSYM
@reagent
reagent / pad.c
Last active December 15, 2015 18:59
dat pad
char *
pad(char *in, size_t width)
{
char *padded = NULL,
*fmt = NULL;
check(asprintf(&fmt, "%%%lds", width) >= 0);
check(asprintf(&padded, fmt, in) >= 0);
free(in);