home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-12 | 24.6 KB | 1,239 lines |
- NAME
- MemHepDeque - retrieves an element from the heap
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepDeque(psHeap,psPriority,ppvData)
- HEAP_P psHeap;
- PSHORT psPriority;
- PVOID * ppvData;
-
- DESCRIPTION
-
- The priority and pvData from psHeap -> psHeapData[0] are
- returned. The heap is adjusted as necessary after the
- call.
-
- HEAP_P psHeap; /* main heap structure */
- PVOID pvData; /* for MemHepDeq() */
- SHORT sPriority; /* for MemHepDeq() */
-
- C_STATUS = MemHepInit(&psHeap,10); /* init for 10 members */
-
- C_STATUS = MemHepEnq(psHeap, 7, ptrToData); /* prio = 7 */
-
- C_STATUS = MemHepDeq(psHeap, &sPriority, &pvData);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = element returned
- C_NOTOK = heap empty
-
-
- NAME
- MemHepDown - adjusts a heap after a deque
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepDown(psHeap, sRoot)
- HEAP_P psHeap;
- SHORT sRoot;
-
- DESCRIPTION
-
- Adjusts heap psHeap starting from sRoot. This routine is
- called by MemHepDeque() and there is not reason to call it
- in your application.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemHepEnque - adds an element and its priority to a heap
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepEnque(psHeap,sPriority,pvData)
- HEAP_P psHeap;
- SHORT sPriority;
- PVOID pvData;
-
- DESCRIPTION
-
- Adds pvData (pointer) with sPriority to heap in psHeap.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = element added
- C_NOTOK = element not added, heap full
-
- NAME
- MemHepInit - initialize a heap before use
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepInit(ppsHeap, sNumElms)
- HEAP_PP ppsHeap;
- SHORT sNumElms;
-
- DESCRIPTION
-
- Initializes a heap through (*ppsHeap) to have sNumElms elements.
-
- The heap is implemented in MemHep*** functions by using a header
- structure (HEAP_T) which contains a pointer to an array of
- data structures (HEAP_DATA_T). MemHepInit() must be called
- prior to any of the other MemHep*** functions.
-
- HEAP_P psHeap; /* main heap structure */
- PVOID pvData; /* for MemHepDeq() */
- SHORT sPriority; /* for MemHepDeq() */
-
- C_STATUS = MemHepInit(&psHeap,10); /* init for 10 members */
-
- C_STATUS = MemHepEnq(psHeap, 7, ptrToData); /* prio = 7 */
-
- C_STATUS = MemHepDeq(psHeap, &sPriority, &pvData);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemHepSwap - swaps two HEAP_DATA_T elements
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepSwap(psHeap1,psHeap2)
- HEAP_DATA_P psHeap1;
- HEAP_DATA_P psHeap2;
-
- DESCRIPTION
-
- Uses memcpy() to swap two HEAP_DATA_T elements.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemHepUp - adjusts a heap after a Enque
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepUp(psHeap)
- HEAP_P psHeap;
-
- DESCRIPTION
-
- Adjuts a heap through psHeap after a MemHepEnque() call.
-
- This is an MemHep*** internal function and there should
- not be any reason to call this from your program.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemHepVacateHeap - removes all entries from a heap.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepVacateHeap(ppsHeap,fFreeData)
- HEAP_PP ppsHeap;
- BOOL fFreeData;
-
- DESCRIPTION
-
- Typically used when all done with a heap. All alloc'ed
- memory via (*ppsHeap) is free()'ed. If fFreeData is
- C_TRUE, each HEAP_DATA_T will be checked and if
- the -> pvData pointer is not NULL, it will free() on
- the -> pvData.
-
- HEAP_P psHeap; /* main heap structure */
- PVOID pvData; /* for MemHepDeq() */
- SHORT sPriority; /* for MemHepDeq() */
-
- /*
- ** Create heap, init for 10 elements
- */
-
- C_STATUS = MemHepInit(&psHeap,10);
-
- C_STATUS = MemHepEnq(psHeap, 7, ptrToData); /* prio = 7 */
-
- C_STATUS = MemHepDeq(psHeap, &sPriority, &pvData);
-
- C_STATUS = MemHepVacateHeap(&psHeap, C_TRUE); /* remove heap */
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemLstAddAfterMember - adds a member after another member in a list.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstAddAfterMember(psPrev, psNewMember)
- LLIST_P psPrev;
- LLIST_P psNewMember;
-
- DESCRIPTION
-
- Inserts psNewMember into the linked-list just after psPrev member.
-
- Element psNewMember must have already been allocated via
- MemLstAllocMember().
-
- The link list head pointer is not reset here because we assume
- add afters will never come BEFORE the head pointer.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemLstAddBeforeMember - adds a member before another member in a list.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstAddBeforeMember(psListRoot,psPrev,psNewMember,ppsRetMember)
- LLIST_P psListRoot;
- LLIST_P psPrev;
- LLIST_P psNewMember;
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Inserts psNewMember into the linked-list just before psPrev member.
-
- Element psNewMember must have already been allocated via
- MemLstAllocMember().
-
- The link list head pointer may be modified so it is passed in via
- psListRoot and returned via ppsRetMember;
-
- C_STATUS = MemLstAddBeforeMember(psListRoot,
- psPrev,
- psNewMember,
- &psListRoot);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemLstAllocMember - allocates a new list member.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstAllocMember(ppsRetMember)
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Allocates a new list member.
-
- All MemLst*** functions use the doubly-linked list structure:
-
- struct LLIST_S
- {
- struct LLIST_S *psPrev; /* pointer to previous member */
- struct LLIST_S *psNext; /* pointer to next member */
- VOID *pvData; /* pointer to data */
- };
-
- typedef struct LLIST_S LLIST_T; /* _T = stucture */
- typedef LLIST_T *LLIST_P; /* _P = pointer to structure */
- typedef LLIST_T **LLIST_PP; /* _PP = address/pointer to pointer */
-
-
-
- LLIST_P psNewMember;
-
- C_STATUS = MemLstAllocMember(&psNewMember);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - member allocated
- (pointer not NULL on return)
- C_NOTOK - member could not be allocated
- (pointer NULL on return)
-
-
- NAME
- MemLstDeleteMember - deletes a member from a list
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstDeleteMember(psListRoot,psMember,ppsRetMember)
- LLIST_P psListRoot;
- LLIST_P psMember;
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Deletes psMember from list psListRoot. Element psListRoot is
- returned via ppsRetMember.
-
- C_STATUS = MemLstDeleteMember(psListRoot,
- psMember,
- &psListRoot);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- WARNINGS
-
- MemLstDeleteMember does NOT free the pvData that the member
- is pointing too. That is the applications responsibility.
- You may not want the pvData to be freed but just the list
- members themselves. (A case for this is when moving data
- from one list to another.)
-
- Also check MemLstUnlinkMember().
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
-
-
- NAME
- MemLstFindMember - search a list to find a member
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstFindMember(psListRoot,pvData,compare_func,psRetMember)
- LLIST_P psListRoot;
- PVOID pvData;
- SHORT (*compare_func)();
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Searches list psListRoot for pvData using compare_func. If a
- match is found between the passed pvData and member -> pvData
- then the address of the member is returned via ppsRetMember.
-
- LLIST_P psSearchMember = NULL;
-
- ....
-
- C_STATUS = MemLstFindMember(psListRoot,
- (PCHAR) "1234",
- compare_func,
- &psSearchMember);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- (ppsRetMember = NULL on return if not found)
-
- (ppsRetMember != NULL on return not found)
-
-
-
- NAME
- MemLstFindTailMember - find the tail (last) member in a list
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstFindTailMember(psListRoot,ppsRetMember)
- LLIST_P psListRoot;
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Walks through the list starting at psListRoot and goes to the end.
- The tail (last) member of the list is returned in ppsRetMember.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
-
- NAME
- MemLstInsertMember - inserts a new member into a list
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstInsertMember(psListRoot,psMember,compare_func,ppsRetMember)
- LLIST_P psListRoot;
- LLIST_P psMember;
- SHORT (*compare_func)();
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Inserts psMember into list starting at psListRoot by using
- compare_func. Places entries in list in ascending order.
- The compare function must emulate the return values of memcmp().
- The head of the list is returned via ppsRetMember. Element
- psMember must have been allocated via MemLstAllocMember.
-
-
- C_STATUS = MemLstInsertMember(psListRoot,
- psMember,
- compare_func,
- &psListRoot);
-
- Note: The MemLst*** functions provide more flexibility on
- how data is added (Insert, AddBefore, AddAfter) than
- the MemQue*** or MemStk functions. For this reason,
- the parameter to the MemLst*** (and MemTre***) functions
- is the member (or node) to be added and not just the
- data itself.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- WARNINGS
-
- Duplicate 'keys' are allowed.
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
-
- NAME
- MemLstUnlinkMember - Unlinks a member from a list
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstUnlinkMember(psListRoot,psMember,ppsRetMember)
- LLIST_P psListRoot;
- LLIST_P psMember;
- LLIST_PP ppsRetMember;
-
- DESCRIPTION
-
- Unlinks psMember from list psListRoot. Element psListRoot is
- returned via ppsRetMember.
-
- C_STATUS = MemLstUnlinkMember(psListRoot,
- psMember,
- &psListRoot);
-
- The difference between MemLstUnlinkMember and MemLstDeleteMember
- is that the delete does a full delete (remove and free) whereas
- the unlink does un-hooks the member from the list but does not
- free it. Unlink is usefull when you need to rearrange members
- within a list.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemLstVacateList - removes all members from a list
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemLstVacateList(ppsListRoot,fFreeData)
- LLIST_PP ppsListRoot;
- BOOL fFreeData;
-
-
- DESCRIPTION
-
- Traverses the list starting at (*ppsListRoot). At each member,
- checks if fFreeData is C_TRUE; if it is, then does a free on
- each members -> pvData. Always does a free on the member itself.
- If (*ppsListRoot) was the head/root of the list, then is reset
- to NULL on return.
-
- C_STATUS = MemLstVacateList(&psListRoot,C_FALSE);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemQueDeqMember - dequeues a member from a list/queue
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemQueDeqMember(ppsListHead,ppsListTail, ppvData)
- LLIST_PP psListHead;
- LLIST_PP psListTail;
- PVOID * ppvData;
-
- DESCRIPTION
-
- Removes a member from the (FIFO) queue and sets (*ppvData) to the
- address that the queue member -> pvData had.
-
- The queue is implemented using the LLIST_T types which the
- MemLst*** functions use. The main difference between the
- MemQue*** and MemLst*** functions is that the creation and
- deletion of the LLIST_P entries is handled AUTOMATICALLY
- for your application by the MemQue*** functions.
-
- LLIST_P psQueHead = NULL;
- LLIST_P psQueTail = NULL;
- PVOID pvData;
-
- pvData = (PVOID) &something;
-
- C_STATUS = MemQueEnqMember(&psQueHead,&psQueTail,pvData);
-
- C_STATUS = MemQueDeqMember(&psQueHead,&psQueTail,&pvData);
-
-
- If you want a LIFO queue rather then FIFO queue, then check
- the MemStk*** stack functions.
-
- There is no MemQueVacateQueue() function. Since the
- queue is maintained using the MemLst*** functions, to vacate
- a queue, set the tail pointer to null, then send the head
- pointer into MemLstVacateList().
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemQueEnqMember - Adds/queues a member into a list/queue
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemQueEnqMember(ppsListHead,ppsListTail, pvData)
- LLIST_PP psListHead;
- LLIST_PP psListTail;
- PVOID pvData;
-
- DESCRIPTION
-
- Adds a member to the (FIFO) queue. The member will hold the
- value of pvData in its -> pvData.
-
- The queue is implemented using the LLIST_T types which the
- MemLst*** functions use. The main difference between the
- MemQue*** and MemLst*** functions is that the creation and
- deletion of the LLIST_P entries is handled AUTOMATICALLY
- for your application by the MemQue*** functions.
-
- LLIST_P psQueHead = NULL;
- LLIST_P psQueTail = NULL;
- PVOID pvData;
-
- pvData = (PVOID) &something;
-
- C_STATUS = MemQueEnqMember(&psQueHead,&psQueTail,pvData);
-
- C_STATUS = MemQueDeqMember(&psQueHead,&psQueTail,&pvData);
-
- If you want a LIFO queue rather then FIFO queue, then check
- the MemStk*** stack functions.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemStkClearStack - initializes a stack pointer to NULL
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemStkClearStack(ppsLlistStack)
- LLIST_PP ppsLlistStack;
-
- DESCRIPTION
-
- Initializes a stack pointer to NULL.
-
- Call this before any other MemStk*** functions.
-
-
- Stacks are implemented here in link list using the
- MemLst routines.
-
- Stacks are also known as LIFO (Last In First Out) Queues
-
- Push a stack and that member is placed on top
- Pop a stack and top member is returned and removed
-
-
- Top of Stack StackMember -> Pointer to data to hold/remember
- |
- v
- StackMember -> Pointer to data to hold/remember
- |
- v
- Bot of Stack StackMember -> Pointer to data to hold/remember
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemStkEmptyStack - initializes a stack pointer to NULL
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemStkEmptyStack(psLlistStack,bEmpty)
- LLIST_P psLlistStack;
- BOOL * bEmpty;
-
- DESCRIPTION
-
- Determines if stack (psLlistStack) is empty.
- Result is returned in (*bEmpty).
-
- LLIST_P psStack;
- BOOL fEmpty;
-
- /* clear stack at program start only */
-
- C_STATUS = MemStkClearStack(&psStack);
-
- C_STATUS = MemStkEmptyStack(psStack,&fEmpty)
-
- if(fEmpty)
- /* stack is empty */
- else
- /* stack is not empty */
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemStkPop - removes/pops an element off the stack
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemStkPop(ppsLlistStackHead,ppvElementPointer)
- LLIST_PP ppsLlistStackHead;
- PVOID * ppvElementPointer;
-
- DESCRIPTION
-
- Removes an element from the top of the stack and sets
- (*ppvElementPointer) to the pvData which was saved from
- the original MemStkPush().
-
- LLIST_P psStack;
- PVOID pvData;
-
- pvData = somedata;
-
- /* clear stack at program start only */
-
- C_STATUS = MemStkClearStack(&psStack);
-
- C_STATUS = MemStkPush(&psStack,pvData);
-
- C_STATUS = MemStkPop(&psStack,&pvData);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- ((*ppvElementPointer) = NULL on return if stack is empty)
-
-
-
- NAME
- MemStkPush - places/pushes an element onto the stack
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemStkPush(ppsLlistStackHead,pvElementPointer)
- LLIST_PP ppsLlistStackHead;
- PVOID pvElementPointer;
-
- DESCRIPTION
-
- Places data (pvElementPointer) onto stack (*ppsLlistStackHead).
-
-
- LLIST_P psStack;
- PVOID pvData;
-
- pvData = somedata;
-
- /* clear stack at program start only */
-
- C_STATUS = MemStkClearStack(&psStack);
-
- C_STAUS = MemStkPush(&psStack,pvData);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MemStkVacateStack - clears all entries from a stack
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemStkVacateStack(ppsLlistStack,fFreeData)
- LLIST_PP ppsLlistStack;
- BOOL fFreeData;
-
-
- DESCRIPTION
-
- Removes all elements from stack (*ppsLListStack).
- If fFreeData = C_TRUE, will also free the data that
- is being pointed to by the stack.
-
- LLIST_P psStack;
- PVOID pvData;
-
- pvData = somedata;
-
- /* clear stack at program start only */
-
- C_STATUS = MemStkClearStack(&psStack);
-
- C_STAUS = MemStkPush(&psStack,pvData);
-
- C_STATUS = MemStkVacateStack(&psStack,C_FALSE);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- ((*ppsLlistStack) = NULL on return)
-
-
-
- NAME
- MemTreAllocNode - allocate a new tree node
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreAllocNode (ppsRetNode)
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Allocates memory for a new tree node. Initializes new node pointers.
- Uses calloc() to obtain the memory.
-
- All MemTre*** functions use the following structure:
-
- struct TNODE_S
- {
- PVOID pvData; /* pointer to application data */
- struct TNODE_S *psLeft; /* left child (internal use) */
- struct TNODE_S *psRight; /* right child (internal use */
- };
-
- typedef struct TNODE_S TNODE_T; /* structure type */
- typedef TNODE_T *TNODE_P; /* pointer to structure */
- typedef TNODE_T **TNODE_PP; /* address/pointer to pointer */
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = allocated node
- (pointer not NULL on return)
- C_NOTOK = could not allocate node
- (pointer NULL on return)
-
-
-
-
-
- NAME
- MemTreDeleteNode - searches for and deletes a node from a tree.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreDeleteNode(psTree,pvData,compare_func,ppsRetNode)
- TNODE_P psTree;
- PVOID pvData;
- SHORT (*compare_func)();
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Searches for pvData starting at psTree. At each node it compares
- the pvData data passed in with each nodes -> pvData by calling
- the compare_func. The compare function must know what type of
- data is being compared. The return values from the compare
- function must emulate those of memcmp()/strcmp().
-
- The new value for psTree is returned in ppsRetNode.
-
- C_STATUS = MemTreDeleteNode(psTree,
- (PVOID) "Testing",
- compare_func,
- &psTree);
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - node found and deleted
- C_NOTOK - node not found
-
-
- NAME
- MemTreFindNode - searches for a node in a tree.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreFindNode(psTree,pvData,compare_func,ppsRetNode)
- TNODE_P psTree;
- PVOID pvData;
- SHORT (*compare_func)();
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Searches for pvData starting at psTree. At each node it compares
- the pvData data passed in with each node -> pvData by calling
- the compare_func(). The compare function must know what type of
- data is being compared. The return values from the compare
- function must emulate those of memcmp()/strcmp().
-
- If the data was found, the address of the node member is returned
- via ppsRetNode. If the data was not found, ppsRetNode will be
- set to NULL
-
-
- TNODE_P psTree;
- TNODE_P psSearchNode = NULL;
-
- ....
-
- C_STATUS = MemTreFindNode(psTree,
- (PVOID) "Testing",
- compare_func,
- &psSearchNode);
-
- if(psSearchNode != NULL)
- /* data found */
- else
- /* data not found */
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemTreInsertNode - inserts a new node into a tree.
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreInsertNode(psTree,psNode,compare_func,ppsRetNode)
- TNODE_P psTree;
- TNODE_P psNode;
- SHORT (*compare_func)();
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Inserts psNode into tree psTree using compare_func. New head of
- tree (psNode) is returned via ppsRetNode. The compare function
- must know what type of data is being compared. The return values
- from the compare function must emulate those of memcmp()/strcmp().
-
- TNODE_P psTree;
- TNODE_P psNewNode;
-
- ....
-
- C_STATUS = MemTreAllocNode(&psNewNode);
-
- C_STATUS = MemTreInsertNode(psTree,
- psNewNode,
- compare_func,
- &psTree);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- WARNINGS
-
- Duplicate 'keys' are permitted. Duplicates (via pvData) are
- inserted in first-appearance order.
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemTreLeaf - determines if a tree node is a leaf
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreLeaf(psTnode)
- TNODE_P psTnode;
-
- DESCRIPTION
-
- Determines if a tree node is a leaf (no left or right children).
- Is used internally by other MemTre*** functions.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = Node is a leaf
- C_NOTOK = Node is not a leaf
-
-
- NAME
- MemTreRotateNodeLeft - rotates a tree node to the Left
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreRotateNodeLeft(psTnode,ppsRetNode)
- TNODE_P psTnode;
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Rotates a tree node to the Left.
- Is used internally by other MemTre*** functions.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = Always returned
-
- NAME
- MemTreRotateNodeRight - rotates a tree node to the right
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreRotateNodeRight(psTnode,ppsRetNode)
- TNODE_P psTnode;
- TNODE_PP ppsRetNode;
-
- DESCRIPTION
-
- Rotates a tree node to the right.
- Is used internally by other MemTre*** functions.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK = Always returned
-
- NAME
- MemTreVacateTree - deletes all nodes in a tree
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreVacateTree(ppsTree, fFreeData)
- TNODE_PP ppsTree;
- BOOL fFreeData;
-
- DESCRIPTION
-
- Traverses the tree starting at (*ppsTree). At each node,
- checks if fFreeData is C_TRUE; if it is, then does a free on
- each nodes -> pvData. Always does a free on the node itself.
- If (*ppsTree) was the head/root of the tree, then is reset
- to NULL on return.
-
- C_STATUS = MemTreVacatetree(&psTreeRoot,C_FALSE);
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemHepSearch - searches a heap for an entry
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemHepSearch(psHeap,pvData,compare_func,ppsHeapData)
- HEAP_P psHeap;
- PVOID pvData;
- SHORT (*compare_func)(PVOID,PVOID);
- HEAP_DATA_PP ppsHeapData;
-
- DESCRIPTION
-
- Searches the heap defined through psHeap. The search is linear
- through each element. The compare_func() is called at each element
- to determine if a match is made between a heap entry and pvData.
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
- (ppsHeapData = NULL if no match)
- (ppsHeapData != NULL if match, is set to heap entry)
-
-
- NAME
- MemTreWalkTree - walks (traverses) a tree
-
- SYNOPSIS
-
- #include <memlib.h>
-
- SHORT APIENTRY
- MemTreWalkTree(psTnode, sOrder, AppFunc)
- TNODE_P psTnode;
- SHORT sOrder;
- SHORT (APIENTRY *AppFunc)(PVOID);
-
- DESCRIPTION
-
- Traverses the tree starting at psTnode. Variable sOrder
- indicates if traversal is C_PRE_ORDER, C_IN_ORDER, or
- C_POST_ORDER. At each leaf (terminal node), the
- application supplied AppFunc is invoked and it is passed
- the current TNODE_P. This is a recursive routine.
-
- The function can be used to process all nodes in a tree
- such as for printing, processing, or deleting.
-
-
- RESOURCE NAME
-
- MEMLIB.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-