delorie.com/archives/browse.cgi | search |
From: | Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Problem with malloc/free |
Date: | Mon, 03 Mar 2003 10:32:30 +0000 |
Lines: | 19 |
Message-ID: | <3E632F3E.6B46C007@phekda.freeserve.co.uk> |
References: | <3E6225AD DOT 1341CC2B AT ec-red DOT com> <Xns933270944F6EBasu1cornelledu AT 132 DOT 236 DOT 56 DOT 8> <3E62BFC8 DOT 4E12DED8 AT ec-red DOT com> <7PD8a.59359$jM5 DOT 151272 AT newsfeeds DOT bigpond DOT com> |
NNTP-Posting-Host: | 62.136.9.84 |
Mime-Version: | 1.0 |
X-Trace: | newsg2.svr.pol.co.uk 1046702183 10253 62.136.9.84 (3 Mar 2003 14:36:23 GMT) |
NNTP-Posting-Date: | 3 Mar 2003 14:36:23 GMT |
X-Complaints-To: | abuse AT theplanet DOT net |
X-Mailer: | Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) |
X-Accept-Language: | de,fr |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Hello. Ben Peddell wrote: [snip] > What about if you added all of the filelengths together, added 80 bytes to > that, and then malloc()'d that space. Then use the first 80 bytes for the > pointer array. Then set each pointer in the array to the right position > within the buffer, so that each pointer points the [length of the previous > file] after the pointer to the previous file. When you're finished, all you > have to do is free() the pointer array, which will automatically free your > entire buffer. Instead of "80 bytes", you should use "sizeof(char *) * 20". If you use "80 bytes", the program is non-portable. Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |