Created
October 31, 2012 18:34
-
-
Save DanBUK/3988945 to your computer and use it in GitHub Desktop.
i don't know what I hate segfaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
int size; | |
short *digits; | |
} IntArray; | |
typedef struct { | |
int size; | |
IntArray **arrays; | |
} IntArrayOfArray; | |
/* pretend an IntArray of size:5 digits[1,2,3,4,5], piecePer:3 */ | |
IntArrayOfArray * functionminified (IntArray *input, int piecePer) { | |
IntArrayOfArray *rtv = (IntArrayOfArray *) malloc(sizeof(IntArrayOfArray)); | |
rtv->size = floor(input->size / piecePer); | |
rtv->arrays = (IntArray *) malloc(rtv->size * sizeof(IntArray)); | |
rtv->arrays[0]->size = 0; // segfaults | |
// .. | |
// .. | |
return rtv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment