Guy Bormann posted a question to the help-hurd mailing list after bowsing Wolfgang Jahrling's Hurd Hacking Guide. The guide looks to be quite useful, saying about itself:
"This document is an introduction to GNU Hurd and Mach programming. The purpose of this guide is to help interested people start hacking the Hurd or extending it (by writing translators). It gives lots of references to the Hurd- or GNU Mach source files. It is recommended that you read through some of these sources. Indeed the Hurd sources are very well written and commented and you can learn a lot by reading them."
Guy's question relates to how various Mach libraries allocate memory, and when it's the progammer's responsibility to free such allocated memory. Marcus Brinkmann offers a detailed reply.
From: Guy Bormann
To: help-hurd AT gnu.org
Subject: Is malloc garbage collecting?
Date: Sun, 14 Apr 2002 14:16:02 +0200
Just out of curiosity I was browsing Wolfgang's "Hurd Hacking
Guide" webpage. In the dump.c example a buffer char* buf is
allocated using malloc() and &buf is passed to the io_*
routine(s). Then, in the /dev/one Hurd-counterpart example is
explained why that should be (i.e. the mmap'ing when the
user-provided return buffer is too small to handle the request).
However, what happens to the originally allocated pointer in the
user program? Is that properly handled by mmap or is this a leak?
(It is OK in small example programs but not for long-running
programs that repeatedly allocate buffers.) Or is there a mistake
in dump.c and should the user program free(buf) when it has
From: Wolfgang J