realloc , malloc and free fails at the same point
realloc , malloc and free fails at the same point and I can not why (memory corruption).
can be because I realloc a zone where I have pointers to mmaped files? Any suggestion are wellcome. |
It would be helpful to see the code to tell you for sure... however, are you trying to realloc a pointer that was mmapped? I'm not so sure that is a wonderful idea.
|
reply
do not realloc pointer to mmaped, realloc zone of pointer to mmaped zone.
like this: typedef struct Pointer_to_mmaped { void *pointer_to_disk; }; struct Pointer_to_mmaped *pointer_to_mmaped; pointer_to_mmaped = (struct Pointer_to_mmaped *) malloc (size); pointer_to_mmaped = realloc (pointer_to_mmaped,size); |
I would use a toll like valgrind to find out why the memory is corrupted.
|
If it's memory-mapped storage, as in "a window to a portion of a disk file," then it does not make logical sense to malloc() it. Apples and oranges.
Anyway, what you did was "you hosed the stack somehow." Maybe it was a double-free, for instance, or you freed memory that had never been allocated. "Mixing memory-mapped stuff and malloc?" :jawa: That would do it... |
All times are GMT -5. The time now is 12:06 AM. |