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
AllocVecTags - Beginner.
- LyleHaze
- AmigaOS Core Developer
- Posts: 525
- Joined: Sat Jun 18, 2011 5:06 pm
- Location: North Florida, near the Big Bend
Re: AllocVecTags - Beginner.
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
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
Re: AllocVecTags - Beginner.
Ops 
didn't notice the semicolon .....
thank you

didn't notice the semicolon .....

thank you
Re: AllocVecTags - Beginner.
Ah, the joys of C. Isn't it wonderful ;-Plorenko wrote:didn't notice the semicolon