From 1d25f4d94b3c8a9482ec2023fd7294d1fd72cc6d Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Thu, 15 May 2025 18:50:24 -0400 Subject: [PATCH] basic gnCreateLinkedList --- src/lists/gryphn_linked_list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lists/gryphn_linked_list.h b/src/lists/gryphn_linked_list.h index f4f51fa..799b912 100644 --- a/src/lists/gryphn_linked_list.h +++ b/src/lists/gryphn_linked_list.h @@ -1,7 +1,22 @@ #pragma once +#include "stdlib.h" // why would one use a linked list typedef struct gnLinkedList { void* data; gnLinkedList* nextNode; } 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; +}