search for: to_add_for_r_alloc

Displaying 1 result from an estimated 1 matches for "to_add_for_r_alloc".

2008 Mar 05
1
R_alloc with structures with "flexible array members"
...rectly, however, it would be better to use R_alloc instead of malloc (memory automagically freed on exit and error; error-checking). But I do not know how to make the call to R_alloc here, since R_alloc allocates n units of size bytes each. I've tried, without success, the following two: int to_add_for_R_alloc = (int) ceil((float) sizeof(struct sequence) / sizeof(unsigned int)); A = (struct sequence *) R_alloc(to_add_for_R_alloc + n, sizeof(unsigned int)); or even a brute force attempt as: A = (struct sequence *) R_alloc( 100, sizeof(struct sequence)); but both result in segmentation faults....