Re: Patch for Inline::C-Cookbook

2002-09-02 Thread Neil Watkiss
Hi Ken, You shouldn't mix this: soldier-name = strdup(name); with this: Safefree(soldier-name); because strdup() is just a C library function that uses malloc(), and Safefree might not be. You want to use savepv(), which is the Perl API's equivalent that's guaranteed to work with

Re: Patch for Inline::C-Cookbook

2002-09-02 Thread Ken Williams
On Monday, September 2, 2002, at 06:41 PM, Neil Watkiss wrote: Hi Ken, You shouldn't mix this: soldier-name = strdup(name); with this: Safefree(soldier-name); because strdup() is just a C library function that uses malloc(), and Safefree might not be. You want to use savepv(),

Re: Patch for Inline::C-Cookbook

2002-09-02 Thread Piers Harding
Perl is full of surprises :-) - I'd never heard of it too, or perlapio ( pointed to herein ) *sigh* so little time so much to learn Cheers. On Tue, Sep 03, 2002 at 12:09:05PM +1000, Ken Williams wrote: On Monday, September 2, 2002, at 06:41 PM, Neil Watkiss wrote: Hi Ken, You

Re: Patch for Inline::C-Cookbook

2002-09-01 Thread Sisyphus
- Original Message - From: Ken Williams [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, September 01, 2002 12:49 AM Subject: Patch for Inline::C-Cookbook Hi, The C-Cookbook has the following code for doing object-oriented Inline: SV* new(char* class, char* name, char

Re: Patch for Inline::C-Cookbook

2002-09-01 Thread Ken Williams
On Monday, September 2, 2002, at 11:35 AM, Sisyphus wrote: Only time I used 'malloc()' and 'free()' in an inline function I struck problems if the function was called a number of times. I forget just how big that 'number of times' was - and the amount of memory involved might well have

Re: Patch for Inline::C-Cookbook

2002-09-01 Thread Iain Truskett
* Ken Williams ([EMAIL PROTECTED]) [02 Sep 2002 15:48]: On Monday, September 2, 2002, at 11:35 AM, Sisyphus wrote: [...] Someone posted the recommendation that 'New()' and 'Safefree()' be used instead, and I've been using them with no trouble. You could be right - I wasn't sure whether

Re: Patch for Inline::C-Cookbook

2002-09-01 Thread Ken Williams
On Monday, September 2, 2002, at 11:35 AM, Sisyphus wrote: Only time I used 'malloc()' and 'free()' in an inline function I struck problems if the function was called a number of times. I forget just how big that 'number of times' was - and the amount of memory involved might well have

Patch for Inline::C-Cookbook

2002-08-31 Thread Ken Williams
Hi, The C-Cookbook has the following code for doing object-oriented Inline: SV* new(char* class, char* name, char* rank, long serial) { Soldier* soldier = malloc(sizeof(Soldier)); SV* obj_ref = newSViv(0); SV* obj = newSVrv(obj_ref, class);