F
f.oppedisano
Hi,
i would like to allocate two structures making only one malloc call.
So i do prt=malloc(sizeof(struct1)+sizeof(struct2));
After this operation i make two pointers one to the first struct (ptr1=ptr),
the other to second struct(ptr2=ptr+sizeof(struct2)).
These two pointer are later used by two threads in mutual exclusion so
thread1 can't access ptr2 and thread2 can't access ptr1.
At some time thread2 wants to free his part of memory but a
free(ptr2) or free((struct struct2 *)ptr) or something similar leads to
a SEGV. This happens, i think, because i must pass to free() a pointer
returned by a previous malloc call. But why this limitation?
Is it possible, in some way, to free only a part of the memory allocated
by malloc?
Remember that i cannot use realloc beacause thread2 cannot access ptr1.
Thank u very much
Francesco Oppedisano
i would like to allocate two structures making only one malloc call.
So i do prt=malloc(sizeof(struct1)+sizeof(struct2));
After this operation i make two pointers one to the first struct (ptr1=ptr),
the other to second struct(ptr2=ptr+sizeof(struct2)).
These two pointer are later used by two threads in mutual exclusion so
thread1 can't access ptr2 and thread2 can't access ptr1.
At some time thread2 wants to free his part of memory but a
free(ptr2) or free((struct struct2 *)ptr) or something similar leads to
a SEGV. This happens, i think, because i must pass to free() a pointer
returned by a previous malloc call. But why this limitation?
Is it possible, in some way, to free only a part of the memory allocated
by malloc?
Remember that i cannot use realloc beacause thread2 cannot access ptr1.
Thank u very much
Francesco Oppedisano