#Read array from array of offsets

1 messages ยท Page 1 of 1 (latest)

muted solar
#

I have an array of offsets, each element of which points to an element of the actual data I want to read.

Here's some pseudocode:

u32 count = read_u32()

u32 offsets[count]
for i in 0..count:
  offsets[i] = read_u32()

data_t data[count]
for i in 0..count:
  fseek(offsets[i])
  data[i] = read_data_t()

I've tried making an array of pointers, but either there's no syntax for that, or I'm doing it wrong.

austere magnet
#

this is how i would do it

#

and then place the file at the desired location

muted solar
#

Thanks for the quick reply, but that's not exactly what I want.
There is a contiguous array of offsets followed by a contiguous array of data.

#

it's offsets... data..., not {offset, data}...

austere magnet
#

this would work though, this does not place the data, it places the data pattern at the offset

#

not in the struct

muted solar
#

ohh, true

#

I'm dumb

austere magnet
#

nah its fine

muted solar
#

alright, thank you very much!

muted solar
austere magnet
#

oh wait

#

no

#

just do

#

data_t data @ offset + addressof(parent);

#

i think this should work

muted solar
#

it does!