Updating cor include guards and separating things from core.h
This commit is contained in:
1 parent
9680f6a923
commit
a9661c3485
5 files changed
+74
-42
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* alloc.h
|
||||
*
|
||||
* Creation Date: 24/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_ALLOC_H
|
||||
#define CMC_COR_ALLOC_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* struct cmc_alloc_node
|
||||
*
|
||||
* Custom allocation node. Allows collections to use custom allocation
|
||||
* functions.
|
||||
*/
|
||||
static struct cmc_alloc_node
|
||||
{
|
||||
void *(*malloc)(size_t);
|
||||
void *(*calloc)(size_t, size_t);
|
||||
void *(*realloc)(void *, size_t);
|
||||
void (*free)(void *);
|
||||
} cmc_alloc_node_default = { malloc, calloc, realloc, free };
|
||||
|
||||
#endif /* CMC_COR_ALLOC_H */
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* callbacks.h
|
||||
*
|
||||
* Creation Date: 24/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_CALLBACK_H
|
||||
#define CMC_COR_CALLBACK_H
|
||||
|
||||
/**
|
||||
* struct cmc_callbacks
|
||||
*
|
||||
* Callback node. Each collection will call one of these functions when:
|
||||
* - create : an element was successfully added to the collection
|
||||
* - read : the collection was successfully queried about an element
|
||||
* - update : an element in the collection was successfully updated
|
||||
* - delete : an element was successfully removed from the collection
|
||||
* - resize : the collection was full and successfully resized
|
||||
*/
|
||||
struct cmc_callbacks
|
||||
{
|
||||
void (*create)(void);
|
||||
void (*read)(void);
|
||||
void (*update)(void);
|
||||
void (*delete)(void);
|
||||
void (*resize)(void);
|
||||
};
|
||||
|
||||
#endif /* CMC_COR_CALLBACK_H */
|
||||
+5
-36
@@ -18,8 +18,8 @@
|
||||
* cmc_flags
|
||||
*/
|
||||
|
||||
#ifndef CMC_CORE_H
|
||||
#define CMC_CORE_H
|
||||
#ifndef CMC_COR_CORE_H
|
||||
#define CMC_COR_CORE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "callbacks.h"
|
||||
#include "flags.h"
|
||||
|
||||
#define CMC_TO_STRING_(X) #X
|
||||
@@ -45,37 +47,4 @@ struct cmc_string
|
||||
|
||||
static const size_t cmc_string_len = 400;
|
||||
|
||||
/**
|
||||
* struct cmc_alloc_node
|
||||
*
|
||||
* Custom allocation node. Allows collections to use custom allocation
|
||||
* functions.
|
||||
*/
|
||||
static struct cmc_alloc_node
|
||||
{
|
||||
void *(*malloc)(size_t);
|
||||
void *(*calloc)(size_t, size_t);
|
||||
void *(*realloc)(void *, size_t);
|
||||
void (*free)(void *);
|
||||
} cmc_alloc_node_default = { malloc, calloc, realloc, free };
|
||||
|
||||
/**
|
||||
* struct cmc_callbacks
|
||||
*
|
||||
* Callback node. Each collection will call one of these functions when:
|
||||
* - create : an element was successfully added to the collection
|
||||
* - read : the collection was successfully queried about an element
|
||||
* - update : an element in the collection was successfully updated
|
||||
* - delete : an element was successfully removed from the collection
|
||||
* - resize : the collection was full and successfully resized
|
||||
*/
|
||||
struct cmc_callbacks
|
||||
{
|
||||
void (*create)(void);
|
||||
void (*read)(void);
|
||||
void (*update)(void);
|
||||
void (*delete)(void);
|
||||
void (*resize)(void);
|
||||
};
|
||||
|
||||
#endif /* CMC_CORE_H */
|
||||
#endif /* CMC_COR_CORE_H */
|
||||
+3
-3
@@ -8,8 +8,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_FLAGS_H
|
||||
#define CMC_FLAGS_H
|
||||
#ifndef CMC_COR_FLAGS_H
|
||||
#define CMC_COR_FLAGS_H
|
||||
|
||||
/**
|
||||
* cmc_flags
|
||||
@@ -40,4 +40,4 @@ const char *cmc_flags_to_str[10] = { "OK", "ALLOC", "EMPTY",
|
||||
"DUPLICATE", "ERROR", "THREAD",
|
||||
"MUTEX" };
|
||||
|
||||
#endif /* CMC_FLAGS_H */
|
||||
#endif /* CMC_COR_FLAGS_H */
|
||||
+3
-3
@@ -12,8 +12,8 @@
|
||||
* Things commonly used by hashtable-based collections.
|
||||
*/
|
||||
|
||||
#ifndef CMC_IMPL_HASHTABLE_H
|
||||
#define CMC_IMPL_HASHTABLE_H
|
||||
#ifndef CMC_COR_HASHTABLE_H
|
||||
#define CMC_COR_HASHTABLE_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -83,4 +83,4 @@ static const size_t cmc_hashtable_primes[] = {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
#endif /* CMC_IMPL_HASHTABLE_H */
|
||||
#endif /* CMC_COR_HASHTABLE_H */
|
||||
Reference in new issue
Block a user