www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/26/19:44:54

Message-ID: <37C55DC3.EB45652@club-internet.fr>
Date: Thu, 26 Aug 1999 17:31:15 +0200
From: flupke <schawat AT club-internet DOT fr>
X-Mailer: Mozilla 4.06 [en] (Win98; I)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Struct Array Allocation, Line Pointers, Automatic Offseting?
References: <199908260412 DOT AAA09411 AT delorie DOT com>
Reply-To: djgpp AT delorie DOT com

Dan Gold wrote:

> I made an 1 dimensional array of a struct and made line pointers to the
> start of each row to make it like a 2 dimensional array.  If I want to
> reference the line pointer as ->line[4][5], it will start on the row index
> 4, but will the 5 jump 5 tiles structs ahead as I allocated or just bytes.

It depends of the declaration of your array. If you declared it as a TILE**,
it will reference TILEs. If you declared it as a char**, it will reference
chars...

> If it does jump ahead structs for me, is there any speed concern when
> multiplying the address location 5 times by the size of the struct? [4th
> row] + [5 * sizeof TILE]

I know DJGPP optimizes (with -Ox) array referencing by doing adds instead of
muls whenever he can. All depends of the context. You can compile your file
with -S to see the assembly output produced.

> One more thing.  Does a struct pointer equal one 32bit address or an
> address for each member of the struct?

The pointer just keeps the starting address of the struct. The members of the
struct are accessed by offseting from the starting address (the offsets are
computed at compile time).


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019