Re: [Rd] Pointer ownership with GECreateDevDesc/GEDestroyDevDesc

2014-09-23 Thread Paul Murrell
This seems like the best solution (free and NULL the dev pointer in dev_Close(), BEFORE GEdestroyDevDesc() has a go). I think this should be safe because dev_Close() and GEdestroyDevDesc() are only called in one place (so your free() should always happen before GEdestroyDevDesc() and your fr

Re: [Rd] Pointer ownership with GECreateDevDesc/GEDestroyDevDesc

2014-09-22 Thread Ritch Melton
I perused the source for RStudio and noticed that they had a similar problem. I didn't think that the GEDevDesc structure was exported, but apparently this is a worthwhile workaround to the defect. void GD_Close(pDevDesc dev) { ...elided... // explicitly free and then null out the dev pointe

[Rd] Pointer ownership with GECreateDevDesc/GEDestroyDevDesc

2014-09-19 Thread Ritch Melton
According to the "R Internals" document, for a custom device, I should create a pDevDesc structure that gets passed to GECreateDevDesc. ..elided... pDevDesc dev; /* Allocate and initialize the device driver data */ if (!(dev = (pDevDesc) calloc(1, sizeof(DevDesc return 0; /* or error() */ /* s