AllocVecTags - Beginner.

This forum is for general developer support questions.
Post Reply
lorenko
Posts: 16
Joined: Sun Aug 19, 2012 11:30 am

AllocVecTags - Beginner.

Post by lorenko »

Hi I'm a beginner can you help me?

my program crash after first allocation

this is the code:

.....
// Global vars
STRPTR *nP = NULL;
uint32 *pds = NULL;
.....
uint32 function(VOID)
{
uint32 count;
count =10;

if (!(pds = (uint32*)IExec->AllocVecTags((count * sizeof(uint32)),
AVT_Type, MEMF_SHARED,
AVT_Lock, FALSE,
AVT_ClearWithValue, 0,
TAG_END)));
{
IDOS->Printf("Alloc 1 failed\n");
return 1;
}
if (!(nP =(STRPTR*)IExec->AllocVecTags((count*sizeof(STRPTR)),
AVT_Type, MEMF_SHARED,
AVT_Lock, FALSE,
TAG_END)));
{
IDOS->Printf("Alloc 2 failed\n");
return 1;
}
........
}

Program output:

Alloc 1 failed

then program crash, the windows is impossible to close and after a few seconds the whole system freeze
(Always after any crash DSI error from OWb or other programs the whole system freeze!!!!)
thx
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 5:06 pm
Location: North Florida, near the Big Bend

Re: AllocVecTags - Beginner.

Post by LyleHaze »

WHen using
If(condition)
{
//response block here
}

it works fine.
But if you put a semicolon after the (condition) then the response block will ALWAYS execute,
no matter what the condition is.

If you remove the semicolon after the condition expression, then the returns will work as expected.

I have no idea why it crashes, but the code posted here works once the semicolon is removed.

LyleHaze
lorenko
Posts: 16
Joined: Sun Aug 19, 2012 11:30 am

Re: AllocVecTags - Beginner.

Post by lorenko »

Ops :)
didn't notice the semicolon ..... :oops:

thank you
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

Re: AllocVecTags - Beginner.

Post by ChrisH »

lorenko wrote:didn't notice the semicolon
Ah, the joys of C. Isn't it wonderful ;-P
Post Reply