Brian Schröder
1/26/2005 7:11:00 PM
Hello Group,
I'm right now learning to write C extensions and it works quite good. The only problem is, that my C was never very profound and I seem to have forgotten all of it in the meantime. So obviously I write a lot of bugs. The question is, how do I debug them.
Right now I'm using printf to output things to the console, but I'd rather like to debug the process in somethink like ddd. Is this possible?
I tried to connect to the running process, but it said to me that the process was "no program".
And now the OT question:
anybody knows of a compact C manual on the web, where I can for example learn how in this code:
/* Structure containing the volume data */
typedef struct {
unsigned long width, height, depth, length;
double *data;
} SRVolume;
/* Create a new SRVolume Datastructure, initialized to size 0x0x0
* Is this allocation method correct, or am I copying the data onto the
* stack and back?
*/
SRVolume rvAlloc() {
SRVolume *result = calloc(1, sizeof(SRVolume));
result->data = calloc(0, sizeof(double));
return(*result);
}
the result data data is returned? I'd think that there is no copying of large amounts of data involved, but I'm not 100% shure because I haven't found a good manual explaining this yet.
Additionally I get under special circumstances (Creating a volume, setting a value and using p(volume)) the message that it tries to free a wrong pointer. If i change p(volume) to puts volume.inspect it works. This is shurely not enough description, but maybe you could point me to some more information on the GC and other things that can bring forth this error message.
Best regards,
Brian