Permalink
Cannot retrieve contributors at this time
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?
dynarrc/dynarrc/dynarrc.freeseglistonce.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (31 sloc)
1.05 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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__ |