Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void **allocateArray(size_t nmemb, size_t *membsize) {
- void *array;
- unsigned long **arr;
- array = calloc(nmemb, sizeof(void*));
- if( !array ) {
- perror("malloc: ");
- return NULL;
- }
- arr = (unsigned long**)array;
- for(int i = 0; i < nmemb; ++i) {
- arr[i] = malloc(membsize[i]);
- if( !arr[i] ) {
- perror("malloc: ");
- return NULL;
- }
- memset(arr[i], 0, membsize[i]);
- }
- return (void**)array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement