[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] C language modification using TinyCC - problems
From: |
Peter Fröhlich |
Subject: |
Re: [Tinycc-devel] C language modification using TinyCC - problems |
Date: |
Sun, 22 May 2005 01:07:54 -0700 |
Hi all,
On May 20, 2005, at 14:03, James Dunne wrote:
The problem is at it's worst when multiple concatenations are strung
together as in s1 ~ s2 ~ s3. You lose the reference to the char *
allocated by s1 ~ s2 since it is fed into ~ s3. Perhaps this should
be disallowed and only ~= should exist.
I might be wrong, but isn't this a *basic* problem in languages that
are not garbage collected? You simply can't allow basic operators that
can be composed into arbitrary expressions to allocate memory, you'll
always have a leak if you do.
What am I missing, i.e. how can you ensure you're leak-free? Especially
in light of stuff like
s1 ~ f(t1 ~ t2) ~ s2
where you have an intervening function call as well (which, I assume,
you don't rule out)? Of course in this case some blame could be put on
the author of f() as well...
Peter
PS: And of course in this light the interface of malloc() is hopelessly
flawed, it should not return a pointer but rather write the address it
allocated to a pointer that is passed in by reference...
--
Peter H. Froehlich <><><><><><> http://www.cs.ucr.edu/~phf/
OpenPGP: ABC2 9BCC 1445 86E9 4D59 F532 A8B2 BFAE 342B E9D9