From: "Douglas A. Gwyn" <DAGwyn@null.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] manual suggestions and upas/fs bug
Date: Wed, 18 Sep 2002 08:37:18 +0000 [thread overview]
Message-ID: <3D87DF03.9736895E@null.net> (raw)
In-Reply-To: <20020917111727.U6063@cackle.proxima.alt.za>
Lucio De Re wrote:
> char *p0 = realloc(p, n);
> if (p0 == 0)
> panic ("realloc failed");
> p = p0;
> would be a lot saner. I forget the semantics, but realloc(p, n) need
> not return p even if the reallocation succeeds. What I don't know is
> what happens to the space pointed to by p, I assume it's released.
Actually you don't have to be very careful if you're going to abort
anyway. (Although the returned pointer needs to be checked, even
for a shrink request.) But if you want to recover more intelligently,
you don't want to lose the old pointer if the realloc fails; either
the old data needs to be retained (so you need to use the old pointer)
or else you want to free the old storage (otherwise you have a memory
leak, which will exacerbate the tight-storage situation).
next prev parent reply other threads:[~2002-09-18 8:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-16 19:29 David Swasey
2002-09-17 1:58 ` Lyndon Nerenberg
2002-09-17 8:47 ` Douglas A. Gwyn
2002-09-17 9:17 ` Lucio De Re
2002-09-18 8:37 ` Douglas A. Gwyn [this message]
2002-09-17 4:34 David Swasey
2002-09-17 20:18 ` Lyndon Nerenberg
2002-09-17 4:58 Russ Cox
2002-09-17 13:28 Russ Cox
2002-09-17 23:05 Russ Cox
2002-09-18 2:06 ` Lyndon Nerenberg
2002-09-18 17:03 ` rob pike, esq.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D87DF03.9736895E@null.net \
--to=dagwyn@null.net \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).