🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #315

Re: AVL tree insertion - programming exercise

#315
From: David Brown
Date: Tue, 13 Oct 2026 09:42
28 lines
2156 bytes
On 13/10/2026 10:38, chine.bleu wrote:
> Tim Rentsch wrote:
>> sons[2] array.  These links are basically pointers, but held
>> as uintptr_t so they can take one of the bits to mean "tall",
>> which means taller than the other subtree of the node.  The
>> tree structure should maintain an invariant that at most one
> 
> Memory is cheap. 

Not any more!

> Do not encode tags into low bits of an address unless 
> you really know what your doing.

Agreed, as a principle.

> As a precaution check the return 
> address of malloc
> 
>      p = malloc(m);
>      if ((uintptr_t)p)&1!=0) abort();
> 

malloc always returns an address with suitable alignment for any 
fundamental alignment on the target.  Typically that means at least 
64-bit alignment (and thus the three LSB's are always zero), but it is 
implementation dependent.
Technical Details
Message-ID: <11akuf1$bq6c$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$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!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: AVL tree insertion - programming exercise
Date: Tue, 13 Oct 2026 11:42:57 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <11akuf1$bq6c$1@dont-email.me>
References: <86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 13 Oct 2026 09:42:58 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="387276"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/vn6rjcl6ZwqzjdD+4iGMrFPq91idXMac="; posting-host="0453d936fb977b9ac4728f0f8db2cabc"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:K3akQh5pWp9HyKQe7+dTBDVyNPM= sha256:vBPI9QG2lwcNUI3Ck/6v5E7SV9xk9BFnr0zbD2TLdWM=
	sha1:ppumt645nXadwDkBXvT6xzKeGrs= sha256:Wd+YwsHhNECZB4cwm6HVr9I5TW2PjnBPZ7SeMlWv5QY=
Content-Language: en-GB, nb-NO
In-Reply-To: <11akqm4$c6h9$1@dont-email.me>