[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is malloc garbage collecting?
From: |
Wolfgang Jährling |
Subject: |
Re: Is malloc garbage collecting? |
Date: |
Sun, 14 Apr 2002 18:45:29 +0200 |
User-agent: |
Mutt/1.0.1i |
Wolfgang Jährling <wolfgang@pro-linux.de> wrote:
> Wolfgang Jährling <wolfgang@pro-linux.de> wrote:
> > Looking at what glibc/hurd/fd-read.c does, it seems to be a leak to not
> > check for equality and freeing the buffer. Does anyone agree/disagree?
>
> Well, I think I have to disagree with me here. :*)
And I think that Wolfgang was right (Uh, I'm feeling a bit schizophrenic
today %-)), because the following program does not segfault:
----- snip! -----
#define _GNU_SOURCE 1
#include <hurd.h>
#include <hurd/io.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
int
main (int argc, char **argv)
{
mach_port_t file;
size_t amount = 5;
char *buf = malloc (amount);
char *ptr = buf;
assert (buf != NULL);
assert (argc == 2);
assert ((file = file_name_lookup (argv[1], O_READ, 0)) != MACH_PORT_NULL);
assert (! io_read (file, &buf, &amount, -1, amount + 3));
assert (buf != ptr);
free (ptr);
return 0;
}
----- snap! -----
assert (I did not understand what dealloc means to MiG);
Cheers,
GNU/Wolfgang
--
Wolfgang Jährling <wolfgang@pro-linux.de> \\ http://stdio.cjb.net/
Debian GNU/Hurd user && Debian GNU/Linux user \\ http://www.gnu.org/
The Hurd Hacking Guide: http://www.gnu.org/software/hurd/hacking-guide/
["We're way ahead of you here. The Hurd has always been on the ]
[ cutting edge of not being good for anything." -- Roland McGrath ]