AllocDosObject additional size allocation

This forum is for general developer support questions.
Post Reply
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

AllocDosObject additional size allocation

Post by xenic »

I'm not sure I understand the difference between the ADO_Size and ADO_AddedSIze tags. Do the following statements achieve the same result?

AllocDosObjectTags(DOS_ANCHORPATH, ADO_Size, sizeof(struct AnchorPath) + 256, TAG_DONE);

AllocDosObjectTags(DOS_ANCHORPATH, ADO_AddedSize, 256, TAG_DONE);

Or is there something different about the resulting allocation?
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: AllocDosObject additional size allocation

Post by colinw »

xenic wrote:I'm not sure I understand the difference between the ADO_Size and ADO_AddedSIze tags.
Do the following statements achieve the same result?

AllocDosObjectTags(DOS_ANCHORPATH, ADO_Size, sizeof(struct AnchorPath) + 256, TAG_DONE);
AllocDosObjectTags(DOS_ANCHORPATH, ADO_AddedSize, 256, TAG_DONE);

Or is there something different about the resulting allocation?

You understand it correctly. One is the whole size, the other is added to the base structure size.

However, you should use ADO_Strlen (aka; ADO_AddedSize) for the path buffer allocation
so the size gets linked into the anchorpath->ap_Strlen structure member correctly, otherwise it will be 0
and you won't get anything written into the ap_Buffer when ap_Strlen is 0.

Also, don't use 256 for the path buffer, the MINIMUM path buffer size for any function should be at least 1K bytes.

* DOS_ANCHORPATH : The following tags are for the AnchorPath structure.
*
* ADO_Strlen (uint32) -- This is required to specify the size of,
* and initialise the AnchorPath->ap_Buffer area.
* The size of the additional buffer space is stored in the field
* AnchorPath->ap_Strlen. The AnchorPath allocated in this manner
* is ready to be used with with MatchFirst()/MatchNext().
* You may want to initialize the AnchorPath->ap_Flags and also
* AnchorPath->ap_BreakBits fields first, though.
* Please use the following two tags: ADO_Flags and ADO_Mask. (V50)
*
* ADO_Flags (uint32) -- This is used to specify the value to place in
* the an->ap_Flags field before calling MatchFirst.
* See: <dos/anchorpath.h> for the flags: APF_xxxxx (V50)
*
* ADO_Mask (uint32) -- This tag is used to specify the value to place
* in the an->ap_BreakBits field before calling MatchFirst.
* See: <dos/dos.h> for the flags: SIGBREAKF_xxxxx (V50)
*
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: AllocDosObject additional size allocation

Post by xenic »

@colinw
Thanks for the explanation.
AmigaOne X1000 with 2GB memory - OS4.1 FE
Post Reply