| Q D E V _ H L P _ I T E R A T E ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English
AMIGA - PUBLIC
----------------------------------------------------------------------------
NAME
QDEV_HLP_ITERATE() - Allows to walkthrough Amiga, doubly
linked list.
SYNOPSIS
QDEV_HLP_ITERATE(list, type, node)
QDEV_HLP_ITERATE(struct List *, <type>, <node>)
FUNCTION
This macro allows to traverse the Amiga, doubly linked
list in a manner allowing to read data per node.
INPUTS
list - Address of the list(struct List, struct MinList).
type - Structure that wraps struct Node/struct MinNode
that then defines its primary members.
node - Address of the structure as declared in the code.
RETURNS
No output.
BASES
None.
NOTES
Please note that this macro is unsuitable for list chain
manipulation! Calling 'Remove()' is strictly discouraged
as this may cause unpredictible behaviour!
All OS lists can be traversed with this macro, but some
sort of arbitration must be provided. This is typically
to be Forbid()/Permit() pair.
SEE ALSO
QDEV_HLP_ISLISTEMPTY(), QDEV_HLP_DELTASCAN()
QDEV_HLP_DELTAITER()
EXAMPLE
#include <proto/exec.h>
#include <exec/execbase.h>
#include <proto/alib.h>
#include <qdev.h>
#define MINCHUNKS 128
struct myentry
{
struct Node me_node;
ULONG me_hash;
};
void iteratelibs(void)
{
struct myentry *me;
struct Library *lib;
struct List lh;
void *cluster;
if ((cluster = mem_alloccluster(
sizeof(struct myentry), MINCHUNKS,
MEMF_PUBLIC | MEMF_LARGEST)))
{
NewList(&lh);
/*
* Enter forbidden state and collect entries.
*/
QDEV_HLP_NOSWITCH
(
QDEV_HLP_ITERATE(
&SysBase->LibList, struct Library *, lib)
{
if ((me = mem_getmemcluster(cluster)))
{
me->me_hash =
QDEV_HLP_FNV32IHASH(lib->lib_Node.ln_Name);
AddTail(&lh, (struct Node *)me);
}
else
{
break;
}
}
);
/*
* Now dump the hashes safely.
*/
QDEV_HLP_ITERATE(&lh, struct myentry *, me)
{
FPrintf(
Output(), "me_hash = 0x%08lx\n", me->me_hash);
}
mem_freecluster(cluster);
}
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |