I have to create program, which is able to generate a GML file.
For this purpose I implemented a function GetEdges, this functions should returns three arrays (call by reference).
The signature of the function looks like:
bool GetEdges(DG_NODE_ID **sourceIds, DG_NODE_ID **destIds, int **weights, int *count)
Within the function I want to malloc space:
*sourceIds = (DG_NODE_ID *) malloc(cntEdges * sizeof (DG_NODE_ID));
As soon as I use 4 nodes i get following output:
graph: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr)
(((char *) &((av)->bins[((1) – 1) * 2])) – __builtin_offsetof (struct
malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size)= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) – 1)) & ~((2 * (sizeof(size_t)))
– 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)’ failed.
I tried everything and I do not have any clue why this fails after I use 4 nodes.
I uploaded the whole source code: Download – Source code
It most probably means you are abusing the memory that is allocated by:
Do you have
valgrind? If so, use it. If not, get it and use it if at all possible. (It’s available for many Unix-like systems; it is not available for Windows AFAIK.)