Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
OrbWorks Community Forum • View topic - malloct / free pairing
Page 1 of 1

PostPosted: Mon Mar 06, 2006 4:55 am
by wjl2
Is it necessary to pair the malloct and free as in C, or are these more free heap allocations?

That is, if I do this:

pointer p,q, r;

p = malloct(1, "piics");
q = malloct(1, "picssi");
r = malloct(1, "piifs");

free(q);

In C, this would either a mistake ('r' should have been freed first), or I'd have just freed the memory pointed to be 'q' *AND* 'r' and left that pointed to by 'p' active.

In Pocket C is the 'r' memory still allocated, or not?

If it is, has the 'q' memory actually been freed, or not?

- Bill

PostPosted: Mon Mar 06, 2006 3:08 pm
by dewey
This code is valid and safe in both C and PocketC - the order in which you free things is irrelevant. I have never heard of a dialect of C that has such horrible side effects in its free function.

PostPosted: Tue Mar 07, 2006 8:54 pm
by wjl2
Ach! Of course. I've been using a real-time in-house system for so long I'd forgotten that it's "free" wasn't normal. Thanks for the reminder.