[util] reverse linked list

This commit is contained in:
Milo Turner 2020-02-24 22:59:46 -05:00
父節點 b6f96d8275
當前提交 dce02a9302
共有 2 個檔案被更改,包括 17 行新增0 行删除

14
src/util/functions.c Normal 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
查看文件

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