[Top][All Lists]

[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 <> wrote:
> Wolfgang Jährling <> 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>

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);


Wolfgang Jährling  <>  \\
Debian GNU/Hurd user && Debian GNU/Linux user \\
The 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 ]

reply via email to

[Prev in Thread] Current Thread [Next in Thread]