Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
/* Main interface for array-based linked-list allocator */
// core methods
#define createLLArr(type) SEG_ARR_CREATE(type)
#define useLLArr(type) SEG_ARR_USE(type)
#define initLLArr(type) SEG_ARR_INIT(type)
#define clearLLArr(type) SEG_ARR_CLEANUP(type)
// checks whether a segment is empty/NULL/unusable
#define segNull(seg) DYNARR_SEG_NULL(seg)
// checks whether a segment is not empty/NULL/unusable
#define segNotNull(seg) DYNARR_SEG_NOT_NULL(seg)
// checks whether there is an existing allocation error
#define isAllocError(type) SEG_BANK_ALLOC_VIOLATION(type)
// allocate a new segment for given type
// returns an object of given type
// may be NULL_SEG if some problem occurs
// check using segNull(type, seg) macro
#define allocSeg(type) SEG_ARR_ALLOC_SEG_FUNC(type)()
// release/free a segment for given type
#define freeSeg(type, seg) SEG_ARR_SEG_FREE_SET(type, seg)
// segment at a particular index
// use segNull() to check validity of the returned segment
#define getSegAt(type, index) SEG_ARR_GET_SEG(type, index)
//------- linked-list behavior ------
// returns the next segment
// use segNull() to check validity ofthe returned segment
#define getNextSeg(type, seg) SEG_ARR_GET_SEG(type, SEG_ARR_SEG_NEXT_INDEX(type, seg))
// checks whether the next segment exists
#define hasNext(type, seg) ((seg).nextIndex != EMPTY_INDEX)
// sets the next segment
// this is a ``hard`` action, because it
// modifies the segment in the data structure
#define setNextSeg(type, seg, nextSeg) \
( seg.nextIndex = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->nextIndex) = \
nextSeg.index)
#define getSegData(seg) (\
(seg).data = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->data)\
)
#define setSegData(type, seg, data) \
( (seg).data = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->data) = \
(data))
// marks the segment as NULL/empty
// this is a ``soft`` action, because it
// does not modify/delete the segment in the data structure
#define makeSegNull(seg) do{(seg).index = EMPTY_INDEX;}while(0)
// marks the segment as NULL/empty
// this is a ``hard`` action, because it
// modifies the segment in the data structure
#define makeNextNull(type, seg) do{\
(seg).nextIndex = \
PTR_SEG_FROM_INDEX(type, (seg).index)->nextIndex) = EMPTY_INDEX;\
}while(0)