You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Havard <br...@kheldar.apana.org.au> on 1999/04/09 09:03:00 UTC

APR file_io and memory allocation

  I'm putting together an OS/2 implementation of the file_io stuff and found
that the unix implementation leaks memory. apr_open malloc()s the apr_file_t
and strdup()s the fname but neither are freed at any point. 

  I would think that apr_close() should clean up all memory allocated by
apr_open() but this would prevent file->fname being used after the file is
closed (and this is done in testfile.c).

  If the application is supposed to free() the file handle it will leak the
memory used by fname and anything else that might be added in the future.

Anyone disagree?

--
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: APR file_io and memory allocation

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Fri, 9 Apr 1999 08:00:20 -0400 (EDT), Ryan Bloom wrote:

>Yep, you are correct.  I meant to put that code in, and well silly me, I
>forgot.  I get it in there today.

Ok, while we're fixing things, wouldn't it be a good idea to dup() the file
handle and strdup() the fname in apr_dupfile() ? That way apr_close()ing the
duplicated handle won't mess up the original.

--
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: APR file_io and memory allocation

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
Yep, you are correct.  I meant to put that code in, and well silly me, I
forgot.  I get it in there today.

Thanks a lot,

Ryan

On Fri, 9 Apr 1999, Brian Havard wrote:

>   I'm putting together an OS/2 implementation of the file_io stuff and found
> that the unix implementation leaks memory. apr_open malloc()s the apr_file_t
> and strdup()s the fname but neither are freed at any point. 
> 
>   I would think that apr_close() should clean up all memory allocated by
> apr_open() but this would prevent file->fname being used after the file is
> closed (and this is done in testfile.c).
> 
>   If the application is supposed to free() the file handle it will leak the
> memory used by fname and anything else that might be added in the future.
> 
> Anyone disagree?
> 
> --
>  ______________________________________________________________________________
>  |  Brian Havard                 |  "He is not the messiah!                   |
>  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
>  ------------------------------------------------------------------------------
> 
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.