🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #2148

Re: C pointer question.

#2148
From: Chuck McManis
Date: Wed, 15 Nov 1989 18:50
37 lines
2026 bytes
In article <698@crash.cts.com> wade@pnet01.cts.com (Wade Bickel) writes:
>        I'm writing a set of memory management routines and have run across
>a dereferencing of pointers I cannot seem to express.

Pointers are such fun aren't they ?

>void *ListAlloc(list,size)
>  struct AllocList **list;
>  ULONG size;
>  {
>    (*(*list)).prev = something;   
>  }
>        I've tried all the variations of "*" and "->" I can think of but none
>seem to work.  I'm using Lattice 5.04.
 
Well, assuming that AllocList is defined (so that the compiler knows what the
tags are in the structure) you want to use :
	*list->prev = <expr>;

Note that the precedence of '*' (dereference pointer) is higher than '->'
(dereference and offset) and so *list is the pointer to an AllocList structure
and the -> operator will dereference the tag 'prev'. If you are using 
doubly linked lists you might want to look in the RKM for the Exec list
structures. They provide one of the best list management packages I've seen
in a while. 

>        For the meantime I've seperated the dereferencing into two steps, but
>since it is only done once per routine this seems a waste.  

Well the compiler will probably code it into two steps anyway so it may or
may not be a waste. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@Eng.Sun.COM
These opinions are my own and no one elses, but you knew that didn't you.
"If it didn't have bones in it, it wouldn't be crunchy now would it?!"
Technical Details
Message-ID: <127910@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!gem.mps.ohio-state.edu!apple!sun-barr!newstop!sun!pepper!cmcmanis
References: <698@crash.cts.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!gem.mps.ohio-state.edu!apple!sun-barr!newstop!sun!pepper!cmcmanis
From: cmcmanis%pepper@Sun.COM (Chuck McManis)
Newsgroups: comp.sys.amiga.tech
Subject: Re: C pointer question.
Message-ID: <127910@sun.Eng.Sun.COM>
Date: 15 Nov 89 18:50:42 GMT
References: <698@crash.cts.com>
Sender: news@sun.Eng.Sun.COM
Reply-To: cmcmanis@sun.UUCP (Chuck McManis)
Organization: Sun Microsystems, Mountain View
Lines: 37