xxNA_UserData

AmigaOS users can make feature requests in this forum.
Post Reply
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

xxNA_UserData

Post by OldFart »

Hi,

This concerns the tags regarding UserData in various Reaction gadgets.

Sometimes it provides insufficient storage for the amount of data one wishes to accompany a node. This then requires the allocation of sufficient storage, of which the result and address is then stored in xxNA_UserData. And don't forget to deallocate that space at free node time, otherwise a memoryleak occurs.

Could it be possible to have every relevant gadget have an extra tag, like xxNA_ExtraSpace (uint32) to provide the required extra space at node allocation time? It should default to 4, so as to provide for backward compatibility.

Regards,
OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
Rigo
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 360
Joined: Mon Jan 17, 2011 9:42 pm

Re: xxNA_UserData

Post by Rigo »

Like all tags in AmigaOS, the pairs are passed as 32 bit numbers. The xx_UserData tag is paired with a 32 bit number which usually points to an address that the caller sets up in advance. This could be any arbitrary value (but is normally a pointer to a data structure which only the caller knows about). This can the be accessed by the caller in a different context (sometimes under an intuition interrupt etc). A common use for this would be pointer to "Global Data", which the caller can access rather than making it "global " within the runtime.

All "ti_Tag" and "ti_Data" values are 32bit when passed, there are no exceptions AFAIK.

You may be getting confused with listbrowser.gadget, where the caller can specify extra space be added to a listbrowser "node", which is a completely different scenario.

Simon
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: xxNA_UserData

Post by thomasrapp »

There is LBNA_NodeSize which sounds exactly like what you are looking for. Don't know if other gadgets have this, too.
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: xxNA_UserData

Post by OldFart »

@Rigo

Thanks for your reply, however I do know how the tag system works and I already use it in the way you described.

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: xxNA_UserData

Post by OldFart »

@tomasrapp

Thanks for pointing me in that direction. Actually never seen (in the sence of 'noticed') that particular tag. After consulting the autodocs I found this information:
LBNA_NodeSize (uint32) (V41)
The size in bytes of the public portion of the node structure that
should be allocated. Usually the default (sizeof(struct Node)) will
suffice unless you wish to have a custom node structure embedded
within the ListBrowser node in which case you'd provide the size
of that structure. Then the node returned can be treated as an
instance of your custom node structure.

Defaults to sizeof(struct Node).
However, it eludes me how I could put that extra size to use as I don't know how to access it. Besides, the autodocs mention sizeof(struct Node) for default, whereas I would think it to be the size of the listbrowser node.

After giving it a thought again, I came to the conclusion that my proposed feature could/would break compatibility as the listbrowser node, and also the nodes of other list oriented gadgets, may grow in future releases and additional members will be added at the end of the structure. Keeping the xxNA_UserData at the end of the structure will return a wrong pointer when the xxNA_UserData address is gotten, when an extended structure is applied with a new release.

On the other hand this issue *could* be overcome by keeping the xxNA_UserData member in its location as per reason of compatibility, but initialise it with the address of the user requested extension. But would this then spark off other issues?

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: xxNA_UserData

Post by thomasrapp »

it eludes me how I could put that extra size to use
Seems obvious to me:

Code: Select all

struct myNode {
	struct Node node;
	struct whatever extra;
	};

my_node = AllocListBrowserNode (... LBNA_NodeSize, sizeof(struct myNode), ...);

my_thing = my_node->extra.thing1;
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: xxNA_UserData

Post by OldFart »

@thomasrapp

OK, Thanks for your explanation.

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
Post Reply