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

malloct / free pairing

Discuss PocketC for Palm OS (including Desktop Edition)

Postby wjl2 on Mon Mar 06, 2006 4:55 am

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
wjl2
 
Posts: 2
Joined: Mon Feb 20, 2006 9:29 am
Location: USA

Postby dewey on Mon Mar 06, 2006 3:08 pm

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.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby wjl2 on Tue Mar 07, 2006 8:54 pm

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.
wjl2
 
Posts: 2
Joined: Mon Feb 20, 2006 9:29 am
Location: USA


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 4 guests

cron