[kaffe] gc_free vs. KFREE

Dalibor Topic robilad@yahoo.com
Wed Apr 2 06:04:02 2003


--0-869726709-1049292339=:92726
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

--- Marc Kleine-Budde <kleine-budde@gmx.de> wrote:
> On Mon, Mar 31, 2003 at 08:29:43AM -0800, Dalibor
> Topic wrote:
> > Hi Marc,
> > 
> > --- Marc Kleine-Budde <kleine-budde@gmx.de> wrote:
> > > 
> > > My assumption is that KFREE clears the mem at
> once,
> > > and gc_free marks
> > > the mem to be freed by the garbage  collector?
> Am I
> > > right?
> > 
> > AFAIK, KMALLOC/KFREE should be used for memory
> that
> > does not go through the gc, while
> gc_malloc/gc_free
> > should be used for the rest. Never mix the calls,
> or
> > you'll be in big trouble. KMALLOC/KFREE leave
> memory
> > management to the runtime library, while
> > gc_malloc/gc_free do their own memory management.
> 
> Okay. Remeber never mix gc_* and K* calls. But if
> you have a look at the
> CVS-sources $KAFFE/libraries/clib/native/ZipFile.c
> lines 26-36. The mem
> for the str is alloced via KMALLOC, but later freed
> with gc_free. It
> this a bug?

Yeah, I think so. I've attached a patch to fix it,
(and a similar case below). could you give it a try,
and see if it breaks anything?

cheers,
dalibor topic


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--0-869726709-1049292339=:92726
Content-Type: application/octet-stream; name="zip-file.patch"
Content-Transfer-Encoding: base64
Content-Description: zip-file.patch
Content-Disposition: attachment; filename="zip-file.patch"

SW5kZXg6IGxpYnJhcmllcy9jbGliL25hdGl2ZS9aaXBGaWxlLmMKPT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2N2cy9rYWZmZS9rYWZmZS9s
aWJyYXJpZXMvY2xpYi9uYXRpdmUvWmlwRmlsZS5jLHYKcmV0cmlldmluZyBy
ZXZpc2lvbiAxLjE2CmRpZmYgLXUgLXIxLjE2IFppcEZpbGUuYwotLS0gbGli
cmFyaWVzL2NsaWIvbmF0aXZlL1ppcEZpbGUuYwk2IEphbiAyMDAzIDE3OjE0
OjI2IC0wMDAwCTEuMTYKKysrIGxpYnJhcmllcy9jbGliL25hdGl2ZS9aaXBG
aWxlLmMJMiBBcHIgMjAwMyAxMzo0NDo0NSAtMDAwMApAQCAtMzEsNyArMzEs
NyBAQAogCiAJc3RyID0gY2hlY2tQdHIoc3RyaW5nSmF2YTJDKGZuYW1lKSk7
CiAJemlwID0gb3BlbkphckZpbGUoc3RyKTsKLQlnY19mcmVlKHN0cik7CisJ
S0ZSRUUoc3RyKTsKIAlyZXR1cm4gKChzdHJ1Y3QgSGthZmZlX3V0aWxfUHRy
Kil6aXApOwogfQogCkBAIC01Niw3ICs1Niw3IEBACiAKIAlzdHIgPSBjaGVj
a1B0cihzdHJpbmdKYXZhMkMoem5hbWUpKTsKIAllbnRyeSA9IGxvb2t1cEph
ckZpbGUoKGphckZpbGUqKXppcCwgc3RyKTsKLQlnY19mcmVlKHN0cik7CisJ
S0ZSRUUoc3RyKTsKIAlpZiAoZW50cnkgPT0gMCkgewogCQlyZXR1cm4gKDAp
OwogCX0K

--0-869726709-1049292339=:92726--