Article View: comp.lang.c
Article #333Re: AVL tree insertion - programming exercise
From: Dan Cross
Date: Tue, 13 Oct 2026 14:34
Date: Tue, 13 Oct 2026 14:34
25 lines
1851 bytes
1851 bytes
In article <11al0l0$eefv$1@dont-email.me>, James Kuyper <jameskuyper@alumni.caltech.edu> wrote: >On 13/10/2026 10:38, chine.bleu wrote: >...> As a precaution check the return >> address of malloc >> >> p = malloc(m); >> if ((uintptr_t)p)&1!=0) abort(); > >Just to be pedantic, the standard doesn't guarantee that the expression >you use will test what you want to test. Since there is a guarantee that >malloc() returns a universally aligned memory, I think it's actually >more likely that the test will fail than that malloc() will fail, though >both probabilities are quite negligible, so it's hard to be sure. The syntax and precedence errors aside, the test is clearly meant to ensure that the low bit in the return from `malloc` is clear, so that it can be repurposed for other things. It should likely be: p = malloc(m); if (p == NULL || ((uintptr_t)p & 1) != 0) abort(); - Dan C.
Technical Details
Message-ID:
<11alfgs$t7q$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$1@dont-email.me> <11al0l0$eefv$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c Subject: Re: AVL tree insertion - programming exercise Date: Tue, 13 Oct 2026 14:34:04 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11alfgs$t7q$1@reader2.panix.com> References: <86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$1@dont-email.me> <11al0l0$eefv$1@dont-email.me> Injection-Date: Tue, 13 Oct 2026 14:34:04 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="29946"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)