master ohmu/fastfetch-openbsd / src / common / impl / FFlist.c
ohmu  ·  2026-10-15
 1#include "common/FFlist.h"
 2
 3#include <stdlib.h>
 4#include <string.h>
 5
 6bool ffListShift(FFlist* list, uint32_t elementSize, void* __restrict result) {
 7    if (list->length == 0) {
 8        return false;
 9    }
10
11    memcpy(result, list->data, elementSize);
12    memmove(list->data, list->data + elementSize, (size_t) elementSize * (list->length - 1));
13    --list->length;
14    return true;
15}
16
17bool ffListPop(FFlist* list, uint32_t elementSize, void* __restrict result) {
18    if (list->length == 0) {
19        return false;
20    }
21
22    memcpy(result, ffListGet(list, elementSize, list->length - 1), elementSize);
23    --list->length;
24    return true;
25}