MCPcopy Create free account
hub / github.com/TurningWheel/Barony / list_AddNodeFirst

Function list_AddNodeFirst

src/list.cpp:197–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195-------------------------------------------------------------------------------*/
196
197node_t* list_AddNodeFirst(list_t* list)
198{
199 if ( !list )
200 {
201 return nullptr;
202 }
203
204 node_t* node;
205
206 // allocate memory for node
207 if ( (node = (node_t*) malloc(sizeof(node_t))) == NULL )
208 {
209 printlog( "failed to allocate memory for new node!\n" );
210 exit(1);
211 }
212
213 // initialize data pointers to NULL
214 node->element = NULL;
215 node->deconstructor = NULL;
216 node->size = 0;
217 node->prev = NULL;
218
219 // integrate it into the list
220 node->list = list;
221 if ( list->first != NULL )
222 {
223 // there are prior nodes in the list
224 node->next = list->first;
225 list->first->prev = node;
226 }
227 else
228 {
229 // inserting into an empty list
230 node->next = NULL;
231 list->last = node;
232 }
233 list->first = node;
234
235 return node;
236}
237
238/*-------------------------------------------------------------------------------
239

Callers 15

createChestInventoryFunction · 0.85
actDeathGhostFunction · 0.85
ttfTextHashStoreFunction · 0.85
loadMapFunction · 0.85
summonMonsterNoSmokeFunction · 0.85
actMonsterFunction · 0.85
actFociGibFunction · 0.85
generatePathFunction · 0.85
summonChestFunction · 0.85

Calls 1

printlogFunction · 0.85

Tested by

no test coverage detected