AutoDocs: exec errors & dicrepancies
Posted: Mon Jan 30, 2012 7:47 pm
Chapter . . .: StartDMA
Section . . .: EXAMPLE
The example wrongly calls IExec->AllocSysObject() where it should call IExec->AllocSysObjectTags().
This allocation is with (struct DMAList *) cast to a non-existent structure. This cast should have been (struct DMAEntry *).
This allocation is then freed by a IExec->FreeVec(), where it should be freed by a call to IExec->FreeSysObject().
Here's the corrected example:
/*
** This example assumes you want to make a DMA write transfer to
** addr, size bytes
*/
ULONG endFlags = 0;
/*
** Tell the system to prepare for DMA
*/
ULONG arraySize = IExec->StartDMA(addr, size, 0);
if (arraySize != 0)
{
/*
** The memory area is prepared, allocate and retrieve the DMA list
*/
struct DMAEntry *DMAList = (struct DMAList *)IExec->AllocSysObjectTags(ASOT_DMAENTRY, ASODMAE_NumEntries, arraySize,
TAG_DONE);
if (DMAList)
{
IExec->GetDMAList(addr, size, 0, DMAList);
/*
** Feed the DMA controller and do stuff
*/
...
/*
** Get rid of the DMAList's memory
*/
IExec->FreeSysObject(ASOT_DMAENTRY, DMAList);
}
else
{
printf("Can't allocate DMA list\n");
endFlags |= DMAF_NoModify;
}
/*
** Note: We still call EndDMA even though the actual transfer
** didn't happen.
*/
IExec->EndDMA(addr, size, endFlags);
}
else
{
printf("Can't initiate DMA transfer\n");
}
===================================================================================================
Chapter . . .: Insert
Section . . .: FUNCTION
Current text:
Insert a node into a doubly linked list AFTER a given node
position. Insertion at the head of a list is possible by passing a
zero value for listNode, though the AddHead function is slightly
faster for that special case.
Proposed text:
Insert a node into a doubly linked list AFTER a given node
position. Insertion at the head of a list is possible by passing a
NULL value for listNode, though the AddHead function is slightly
faster for that special case.
===================================================================================================
Section . . .: EXAMPLE
The example wrongly calls IExec->AllocSysObject() where it should call IExec->AllocSysObjectTags().
This allocation is with (struct DMAList *) cast to a non-existent structure. This cast should have been (struct DMAEntry *).
This allocation is then freed by a IExec->FreeVec(), where it should be freed by a call to IExec->FreeSysObject().
Here's the corrected example:
/*
** This example assumes you want to make a DMA write transfer to
** addr, size bytes
*/
ULONG endFlags = 0;
/*
** Tell the system to prepare for DMA
*/
ULONG arraySize = IExec->StartDMA(addr, size, 0);
if (arraySize != 0)
{
/*
** The memory area is prepared, allocate and retrieve the DMA list
*/
struct DMAEntry *DMAList = (struct DMAList *)IExec->AllocSysObjectTags(ASOT_DMAENTRY, ASODMAE_NumEntries, arraySize,
TAG_DONE);
if (DMAList)
{
IExec->GetDMAList(addr, size, 0, DMAList);
/*
** Feed the DMA controller and do stuff
*/
...
/*
** Get rid of the DMAList's memory
*/
IExec->FreeSysObject(ASOT_DMAENTRY, DMAList);
}
else
{
printf("Can't allocate DMA list\n");
endFlags |= DMAF_NoModify;
}
/*
** Note: We still call EndDMA even though the actual transfer
** didn't happen.
*/
IExec->EndDMA(addr, size, endFlags);
}
else
{
printf("Can't initiate DMA transfer\n");
}
===================================================================================================
Chapter . . .: Insert
Section . . .: FUNCTION
Current text:
Insert a node into a doubly linked list AFTER a given node
position. Insertion at the head of a list is possible by passing a
zero value for listNode, though the AddHead function is slightly
faster for that special case.
Proposed text:
Insert a node into a doubly linked list AFTER a given node
position. Insertion at the head of a list is possible by passing a
NULL value for listNode, though the AddHead function is slightly
faster for that special case.
===================================================================================================