Is it possible to find the size (in bytes) of a segment in a seglist? The seglist would come from LoadSeg(), but might contain 68k & other non-OS4-native segments.
(I am a total novice regarding seglists, but I gather you can walk the list by treating the top of the segment as a pointer.)
On 68k the seglist looks like this:
ULONG size; /* size in longwords, i.e. divided by 4 */
BPTR next; /* BPTR to next segment. Multiply by 4 to get CPTR (use BADDR() macro) */
ULONG data[n]; /* contents of segment */
LoadSeg() returns a BPTR to "next". The "next" pointer also points to the "next" field of the next segment (or 0 if this one is the last one).
For OS4 see struct PseudoSegList in dos/dosextens.h. The comments say that it has a size field before it just like the 68k seglist.
Thanks! So if I treat a segment as an array of "long", where "next" is index 0, then the size is at index "-1", right?
Author of the PortablE programming language.
I love using Amiga OS4.1 on my X1000 & Sam440 :-D
Should be unsigned long, but yes, that's right. Note that the size is given in number of ULONGs, not in number of bytes.
Ah, thanks, I would have got that wrong.
Author of the PortablE programming language.
I love using Amiga OS4.1 on my X1000 & Sam440 :-D
@thomas:
Are you sure that this information is correct? AFAICS the size is in bytes and not in ULONGs under OS3.
No, I am not ;-)
Looking into another program from me it seems you are right, the length is in bytes.