#array of pointers

1 messages · Page 1 of 1 (latest)

topaz dust
#

I can't figure out the syntax/tricks to describe an array-of-pointers. The syntax seems to only support pointer-to-array?

rough lantern
#

Hey, there's no direct syntax for this. Wrap your pointers into a struct and then create an array of that

topaz dust
#

is there a way to get relative-to-parent pointers to not refer to this wrapper struct, then?

rough lantern
#

Alternatively, use calculated pointers using the @ syntax. Then you can do any logic you need in-line

topaz dust
#

So what I'm trying to do is write a pattern for berkeleyDB files, which are page-based (4K, 8K, etc) and all the "pointers" are u16 offsets from the start of the page. Maybe there's some features more on-point for this

topaz dust
#

I also think relative_to_parent is not working how I expect: I have a struct at 0x4000 with a char *highfreeoffset: u16 [[pointer_base("std::ptr::relative_to_parent")]]; member at +0x16. The value is 0x0A04, so I would expect the pointer to be calculated to be 0x4A04, but it's being calculated to be 0x4A1A

#

yeah, std::ptr::relative_to_pointer and std::ptr::relative_to_parent are giving the same result