Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Allocation problems

2 views
Skip to first unread message

a.somm...@googlemail.com

unread,
Apr 28, 2009, 10:14:18 AM4/28/09
to
Hello,

I struggle with very strange behavior of my program. I want to create
two double-arrays and allocate the dynamically. Here's a code snippet:

int someMethod(int, double, double) {

double *start_pos = (double*) calloc(6, sizeof(double));
double *current = (double*) calloc(6, sizeof(double));

...
}

The first line executes successfully but the second one crashes with a
segmentation fault. I'm trying to find the reason for this failure and
found out that I can only allocate on block of 48 bytes at a time in
this method. When I want to allocate memory for *current i first need
to free(start_pos).

That makes no sense to me, since it's only 48 bytes. By the way... 32
bytes seems to be the magic number, so

double *start_pos = (double*) calloc(6, sizeof(double));
double *current = (double*) calloc(4, sizeof(double));

works fine.

Does anyone has an idea? Do I need to specify a greater amount of
memory for my target? I am pretty new to qnx and anything but a C-
Professional ;-)

regards,
Alex

0 new messages