Page 1 of 1

AllocVecTags

Posted: Sat Jan 21, 2012 2:33 pm
by JosDuchIt
What AllocVecTags call would best replace
AllocMem(sizeof(struct Mystruct), 0);
would
AllocVecTags(sizeof(struct Mystruct), TAG_END) do ?

Code: Select all


struct dos_info
{	
	char *cb;			 /* copy buffer */
	LONG cbsize;		 /* size of copy buffer */
	BPTR rootlk; 
	BPTR destlk;
	char rt[25600];		 /* root name, exagerrated length */
	char dest[25600];	 /* destination name, exagerrated length*/
	int  newpath, rootend, destend;
	LONG size;
	LONG protflag;
}; 

int main(void)  ///char *dirname)
{
  struct dos_info *ds; 
if((ds=AllocVecTags(sizeof(struct dos_info),TAG_END)))
	Printf("size %d\n", sizeof(struct dos_info)); /// size 0

FreeVec (ds);
if((ds=AllocVecTags(sizeof(struct dos_info), AVT_Type, MEMF_SHARED, TAG_END)))
	Printf("size %d\n", sizeof(struct dos_info)); /// size 0

FreeVec (ds);

}
In the test i don't see a difference, but then i did not expect to have the Printf idenitfy a size of 0.

Is omething wrong with my test ?

Re: AllocVecTags

Posted: Sat Jan 21, 2012 4:34 pm
by thomasrapp
You need to use %ld. %d is short word but the compiler puts long words on the stack.

Re: AllocVecTags

Posted: Sun Jan 22, 2012 9:16 pm
by JosDuchIt
@thomasrapp
thanks.