[util] reverse linked list

This commit is contained in:
Milo Turner 2020-02-24 22:59:46 -05:00
parent b6f96d8275
commit dce02a9302
2 changed files with 17 additions and 0 deletions

14
src/util/functions.c Normal file
View File

@ -0,0 +1,14 @@
#include "functions.h"
#include <stddef.h>
void* ax__reverse_list(void* l)
{
void* next;
void* rev = NULL;
for (void** list = l; list != NULL; list = next) {
next = *list;
*list = rev;
rev = list;
}
return rev;
}

3
src/util/functions.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void* ax__reverse_list(void* list);