Files
fastfetch/src/common/impl/FFlist.c
T
李通洲 e0eba8ce21 Chore: run clang-format
```bash
find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i
```
2026-03-29 10:03:32 +08:00

35 lines
832 B
C

#include "common/FFlist.h"
#include <stdlib.h>
#include <string.h>
void* ffListAdd(FFlist* list) {
if (list->length == list->capacity) {
ffListReserve(list, list->capacity == 0 ? FF_LIST_DEFAULT_ALLOC : list->capacity * 2);
}
++list->length;
return ffListGet(list, list->length - 1);
}
bool ffListShift(FFlist* list, void* result) {
if (list->length == 0) {
return false;
}
memcpy(result, list->data, list->elementSize);
memmove(list->data, list->data + list->elementSize, (size_t) list->elementSize * (list->length - 1));
--list->length;
return true;
}
bool ffListPop(FFlist* list, void* result) {
if (list->length == 0) {
return false;
}
memcpy(result, ffListGet(list, list->length - 1), list->elementSize);
--list->length;
return true;
}