[Aldor-l] Code audit

David Casperson casper at unbc.ca
Mon Jun 30 13:47:51 EDT 2008


Pippijn, you wrote:

> Hi all,
> 
> in foam.c: foamFrString (String), a Buffer is created, used and then
> liberated. It is not freed. Why not?
> 
> Code:
> 
> Foam
> foamFrString(String s)
> {
>         Foam    foam;
>         Buffer  buf;
>
>         buf = bufCapture(s, stoSize(s));
>         foam = foamFrBuffer(buf);
>         bufLiberate(buf); // <- here
>
>         return foam;
> }

I am also learning compiler internals by reading code.  My
understanding is that the difference between bufFree and
bufLiberate is that the latter does not free the memory that the
buffer points at, just the buffer itself.  This matches
bufCapture, which does not copy the ``String s'', just makes a
buffer that points at it.

Does this seem right?


David
-- 
Dr. David Casperson, Assistant Professor     |  casper at unbc.ca
Department of Computer Science               |  (250)   960-6672 Fax 960-5544
College of Science and Management            |  3333 University Way
University of Northern British Columbia      |  Prince George, BC   V2N 4Z9
                                              |  CANADA




More information about the Aldor-l mailing list