Add two headers, one for the general libds stuff and one for vectors.
This commit is contained in:
parent
5ac2e368a2
commit
043562aacf
17
include/libds.h
Normal file
17
include/libds.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef LIBDS_HEADER
|
||||
#define LIBDS_HEADER
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
enum libds_result_e {
|
||||
SUCCSESS,
|
||||
MALLOC
|
||||
};
|
||||
|
||||
typedef enum libds_result_e libds_result;
|
||||
typedef int (*compare_func)(void*, void*);
|
||||
typedef int (*foreach_func)(void*, va_list);
|
||||
|
||||
int compare_always(void* a, void* b);
|
||||
|
||||
#endif
|
25
include/vec.h
Normal file
25
include/vec.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef LIBDS_VEC_HEADER
|
||||
#define LIBDS_VEC_HEADER
|
||||
|
||||
#define LIBDS_VEC_CAPACITY 4
|
||||
|
||||
#include "libds.h"
|
||||
|
||||
struct vec_s {
|
||||
void* data;
|
||||
int capacity;
|
||||
int size;
|
||||
};
|
||||
|
||||
typedef struct vec_s vec;
|
||||
|
||||
libds_result vec_init(vec*);
|
||||
void vec_free(vec*);
|
||||
|
||||
libds_result vec_add(vec*, void*);
|
||||
void vec_remove(vec*, void*);
|
||||
|
||||
void* vec_find(vec*, void*, compare_func);
|
||||
int vec_foreach(vec*, void*, compare_func, foreach_func, ...);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user