Mistake in cut-and-paste, but not in original code: Move a->nelem++ down after a->y[a->nelem] = y;
Sorry about that....
User Profile
Collapse
-
Repeated realloc causes crash in glibc
Here is the code snippet, realloc succeeds once but fails the next time. I use gcc 4.1.2, glibc 2.5.
...Code:typedef struct array { double *x, *y; size_t nelem, size; } array_t; #define INIT_A_SIZE 1 int init_a(array_t *a) { if (a) { a->x = (double *)malloc(INIT_A_SIZE*sizeof(double)); a->y = (double *)malloc(INIT_A_SIZE*sizeof(double)); if (!a->x
No activity results to display
Show More
Leave a comment: