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
#ifndef __dynarr_only_once__
#define __dynarr_only_once__
// the struct FreeSegNode will be used multiple times, so we do not want to redefine it
struct FreeSegNode{
int index;
struct FreeSegNode* next;
};
typedef struct FreeSegNode FreeSegNode;
#define _FreeSegNodeMalloc() \
( (struct FreeSegNode*) malloc(sizeof(struct FreeSegNode)) )
// Swaps two 32-bit intergers without using temporary variables
#define _SEG_ARR_INT_SWAP(var1, var2) (\
(var1) = (FreeSegNode*) (((int) (void*) var1) ^ ((int) (void*) var2) ), \
(var2) = (FreeSegNode*) (((int) (void*) var1) ^ ((int) (void*) var2) ), \
(var1) = (FreeSegNode*) (((int) (void*) var1) ^ ((int) (void*) var2) ) )
// Given two lists A and B, moves the head of A in front of the
// head of B. Head of A must be non-null.
//
// Before:
// A-->1-2-3-4-5
// B-->a-b-c-d-e
// After:
// A-->2-3-4-5
// B-->1-a-b-c-d-e
//
#define _SEG_ARR_MOVE_LIST_HEAD(listFrom, listTo) \
do{\
_SEG_ARR_INT_SWAP( listFrom->next, listTo); \
_SEG_ARR_INT_SWAP( listFrom, listTo ); \
}while(0)
#endif // __dynarr_only_once__