basic gnCreateLinkedList

This commit is contained in:
Greg Wells
2025-05-15 18:50:24 -04:00
parent befd289983
commit 1d25f4d94b

View File

@@ -1,7 +1,22 @@
#pragma once #pragma once
#include "stdlib.h"
// why would one use a linked list // why would one use a linked list
typedef struct gnLinkedList { typedef struct gnLinkedList {
void* data; void* data;
gnLinkedList* nextNode; gnLinkedList* nextNode;
} gnLinkedList; } gnLinkedList;
static gnLinkedList gnCreateLinkedList(int count) {
gnLinkedList list;
gnLinkedList* currentNode = &list;
for (int i = 0; i < count; i++) {
if ((i + 1) < count) {
currentNode->nextNode = (gnLinkedList*)malloc(sizeof(gnLinkedList));
currentNode = currentNode->nextNode;
}
}
return list;
}