Exception on malloc for a structure in C

Posted by Derek on Stack Overflow See other posts from Stack Overflow or by Derek
Published on 2010-04-26T17:22:34Z Indexed on 2010/04/26 17:33 UTC
Read the original article Hit count: 302

Filed under:
|
|

Hi all,

I have a structure defined like so:

typedef struct {
 int n;
 int *n_p;
 void **list_pp;
 size_t rec_size;
 int n_buffs;
 size_t buff_size
} fl_hdr_type;

and in my code I Have a function for initlialization that has the following

fl_hdr_type *fl_hdr;
fl_hdr = malloc(sizeof(fl_hdr_type) + (buff_size_n * rec_size_n));

where those buffer size are passed in to the function to allow space for the buffers as well.

The size is pretty small typically..100*50 or something like that..plenty of memory on this system to allocate it.

Any ideas why this fails?

© Stack Overflow or respective owner

Related posts about malloc

Related posts about structure