Hi,
I've looked through the valgrind documentation, but I just can't see anything wrong with this line of code:
it's giving an error the if(!ids) line.Code:int* get_replica_ids(const Replica *replicas, int num_replicas) { int *ids = (int*)malloc(sizeof(int) * num_replicas); if(!ids){ fprintf(stderr, "Could not allocate memory for id array.\n"); return NULL; } int i; for(i = 0; i<num_replicas; i++){ ids[i] = replicas[i].replica_id; } return ids; }
The error is
Any idea?Address 0x6a43f38 is 0 bytes after a block of size 8 alloc'd