Add two headers, one for the general libds stuff and one for vectors.

This commit is contained in:
Danila Fedorin 2016-12-20 00:32:34 -08:00
parent 5ac2e368a2
commit 043562aacf
2 changed files with 42 additions and 0 deletions

17
include/libds.h Normal file
View 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
View 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