libcdsb/include/bits/memory.h

41 lines
1.7 KiB
C
Raw Normal View History

2022-06-02 14:20:55 +03:00
/* This software is licensed by the MIT License, see LICENSE file */
/* Copyright © 2022 Gregory Lirent */
#include <stddef.h>
2022-08-22 11:56:16 +03:00
#include "__attributes.h"
2022-06-02 14:20:55 +03:00
2022-08-22 11:56:16 +03:00
#ifndef LIBCDSB_BITS_MEMORY_H
#define LIBCDSB_BITS_MEMORY_H
2022-06-02 14:20:55 +03:00
2022-06-07 21:35:13 +03:00
typedef struct libcdsb_stack_node {
struct libcdsb_stack_node* prev;
void* value;
} stack_t;
2022-09-13 10:37:40 +03:00
typedef struct libcdsb_queue {
struct libcdsb_stack_node* back;
struct libcdsb_stack_node* front;
} queue_t;
2022-08-18 00:08:10 +03:00
extern void libcdsb_stack_init (stack_t* stack) Nonnull__(1);
extern void libcdsb_stack_push (stack_t* stack, void* value) Nonnull__(1);
extern void libcdsb_stack_push_many(stack_t* stack, size_t n, ...) Nonnull__(1);
extern void* libcdsb_stack_pop (stack_t* stack) Nonnull__(1);
extern void libcdsb_stack_reverse (stack_t* stack) Nonnull__(1);
2022-08-18 00:08:10 +03:00
extern void libcdsb_stack_flush (stack_t* stack) Nonnull__(1);
2022-08-16 01:36:37 +03:00
2022-09-13 10:37:40 +03:00
extern void libcdsb_queue_init (queue_t* queue) Nonnull__(1);
extern void libcdsb_queue_push (queue_t* queue, void* value) Nonnull__(1);
extern void libcdsb_queue_push_many(queue_t* queue, size_t n, ...) Nonnull__(1);
extern void* libcdsb_queue_pop (queue_t* queue) Nonnull__(1);
extern void libcdsb_queue_flush (queue_t* queue) Nonnull__(1);
2022-08-16 01:36:37 +03:00
extern void* libcdsb_aalloc (size_t a, size_t n) Warn_unused_result__;
extern void* libcdsb_malloc (size_t n) Warn_unused_result__;
extern void* libcdsb_calloc (size_t n, size_t c) Warn_unused_result__;
extern void* libcdsb_realloc(void *p, size_t n) Warn_unused_result__;
2022-06-02 14:20:55 +03:00
2022-08-17 22:20:04 +03:00
extern void libcdsb_free(void* s);
2022-08-22 11:56:16 +03:00
#endif /* LIBCDSB_BITS_MEMORY_H */