From e3e9fa190b86dfce48a43feed2e5c82522df4bd8 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 17 Apr 2018 09:54:17 +0200 Subject: [PATCH 01/26] Allow an initial number of buckets. It works only with power of 2, otherwise nothing is done. --- src/map.c | 13 +++++++++++++ src/map.h | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/map.c b/src/map.c index 308ccad..b209735 100644 --- a/src/map.c +++ b/src/map.c @@ -108,6 +108,19 @@ static map_node_t **map_getref(map_base_t *m, const char *key) { } +int map_init_(map_base_t *m, unsigned initial_nbuckets) { + // Clear the memory. + memset(m, 0, sizeof(*m)); + + // Pre-initialize buckets array only if initial_nbuckets is a power of 2. + // Anyway, it is reallocated automatically when needed. + if ((initial_nbuckets > 0) && !(initial_nbuckets & (initial_nbuckets - 1))) + return map_resize(m, initial_nbuckets); + else + return 0; +} + + void map_deinit_(map_base_t *m) { map_node_t *next, *node; int i; diff --git a/src/map.h b/src/map.h index 71af710..5b4e027 100644 --- a/src/map.h +++ b/src/map.h @@ -30,8 +30,8 @@ typedef struct { struct { map_base_t base; T *ref; T tmp; } -#define map_init(m)\ - memset(m, 0, sizeof(*(m))) +#define map_init(m, initial_nbuckets)\ + map_init_(&(m)->base, initial_nbuckets) #define map_deinit(m)\ @@ -59,6 +59,7 @@ typedef struct { map_next_(&(m)->base, iter) +int map_init_(map_base_t *m, unsigned initial_nbuckets); void map_deinit_(map_base_t *m); void *map_get_(map_base_t *m, const char *key); int map_set_(map_base_t *m, const char *key, void *value, int vsize); From 7b37760f987b56657345ffd655d1861e3bd2f986 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Mon, 8 Oct 2018 11:34:12 +0200 Subject: [PATCH 02/26] check for null arguments in the API functions. documentation improved. --- README.md | 6 +++++- src/map.c | 55 +++++++++++++++++++++++++++++++++++-------------------- src/map.h | 18 +++++++++--------- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 805b425..7b73159 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,13 @@ into an existing C project and compiled along with it. ## Usage Before using a map it should first be initialised using the `map_init()` function. +The second argument is an integer with the number of buckets to be pre-allocated. +If is not a power of 2 or 0, no pre-allocation is done. It can improve the speed but, +on the other hand, could allocate useless space. ```c map_int_t m; -map_init(&m); +unsigned initial_nbuckets = 128; +map_init(&m, initial_nbuckets); ``` Values can added to a map using the `map_set()` function. diff --git a/src/map.c b/src/map.c index b209735..584430c 100644 --- a/src/map.c +++ b/src/map.c @@ -7,6 +7,7 @@ #include #include +#include #include "map.h" struct map_node_t { @@ -28,10 +29,10 @@ static unsigned map_hash(const char *str) { static map_node_t *map_newnode(const char *key, void *value, int vsize) { - map_node_t *node; int ksize = strlen(key) + 1; + if (ksize > PTRDIFF_MAX) return NULL; int voffset = ksize + ((sizeof(void*) - ksize) % sizeof(void*)); - node = malloc(sizeof(*node) + voffset + vsize); + map_node_t *node = malloc(sizeof(*node) + voffset + vsize); if (!node) return NULL; memcpy(node + 1, key, ksize); node->hash = map_hash(key); @@ -58,10 +59,9 @@ static void map_addnode(map_base_t *m, map_node_t *node) { static int map_resize(map_base_t *m, int nbuckets) { map_node_t *nodes, *node, *next; map_node_t **buckets; - int i; /* Chain all nodes together */ nodes = NULL; - i = m->nbuckets; + unsigned i = m->nbuckets; while (i--) { node = (m->buckets)[i]; while (node) { @@ -94,9 +94,8 @@ static int map_resize(map_base_t *m, int nbuckets) { static map_node_t **map_getref(map_base_t *m, const char *key) { unsigned hash = map_hash(key); - map_node_t **next; if (m->nbuckets > 0) { - next = &m->buckets[map_bucketidx(m, hash)]; + map_node_t **next = &m->buckets[map_bucketidx(m, hash)]; while (*next) { if ((*next)->hash == hash && !strcmp((char*) (*next + 1), key)) { return next; @@ -111,7 +110,7 @@ static map_node_t **map_getref(map_base_t *m, const char *key) { int map_init_(map_base_t *m, unsigned initial_nbuckets) { // Clear the memory. memset(m, 0, sizeof(*m)); - + m->initialized = true; // Pre-initialize buckets array only if initial_nbuckets is a power of 2. // Anyway, it is reallocated automatically when needed. if ((initial_nbuckets > 0) && !(initial_nbuckets & (initial_nbuckets - 1))) @@ -122,42 +121,51 @@ int map_init_(map_base_t *m, unsigned initial_nbuckets) { void map_deinit_(map_base_t *m) { - map_node_t *next, *node; - int i; - i = m->nbuckets; + if (m == NULL) + return; + if (!m->initialized) + return; + unsigned i = m->nbuckets; while (i--) { - node = m->buckets[i]; + map_node_t *node = m->buckets[i]; while (node) { - next = node->next; + map_node_t *next = node->next; free(node); node = next; } } free(m->buckets); + m->initialized = false; } void *map_get_(map_base_t *m, const char *key) { + if (m == NULL || key == NULL) + return NULL; + if (!m->initialized) + return NULL; map_node_t **next = map_getref(m, key); return next ? (*next)->value : NULL; } int map_set_(map_base_t *m, const char *key, void *value, int vsize) { - int n, err; - map_node_t **next, *node; + if (m == NULL || key == NULL || value == NULL) + return -1; + if (!m->initialized) + return -1; /* Find & replace existing node */ - next = map_getref(m, key); + map_node_t **next = map_getref(m, key); if (next) { memcpy((*next)->value, value, vsize); return 0; } /* Add new node */ - node = map_newnode(key, value, vsize); + map_node_t *node = map_newnode(key, value, vsize); if (node == NULL) goto fail; if (m->nnodes >= m->nbuckets) { - n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; - err = map_resize(m, n); + int n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; + int err = map_resize(m, n); if (err) goto fail; } map_addnode(m, node); @@ -170,10 +178,13 @@ int map_set_(map_base_t *m, const char *key, void *value, int vsize) { void map_remove_(map_base_t *m, const char *key) { - map_node_t *node; + if (m == NULL || key == NULL) + return; + if (!m->initialized) + return; map_node_t **next = map_getref(m, key); if (next) { - node = *next; + map_node_t *node = *next; *next = (*next)->next; free(node); m->nnodes--; @@ -190,6 +201,10 @@ map_iter_t map_iter_(void) { const char *map_next_(map_base_t *m, map_iter_t *iter) { + if (m == NULL || iter == NULL) + return NULL; + if (!m->initialized) + return NULL; if (iter->node) { iter->node = iter->node->next; if (iter->node == NULL) goto nextBucket; diff --git a/src/map.h b/src/map.h index 5b4e027..d9a35ce 100644 --- a/src/map.h +++ b/src/map.h @@ -9,8 +9,9 @@ #define MAP_H #include +#include -#define MAP_VERSION "0.1.0" +#define MAP_VERSION "0.1.1" struct map_node_t; typedef struct map_node_t map_node_t; @@ -18,6 +19,7 @@ typedef struct map_node_t map_node_t; typedef struct { map_node_t **buckets; unsigned nbuckets, nnodes; + bool initialized; } map_base_t; typedef struct { @@ -31,24 +33,22 @@ typedef struct { #define map_init(m, initial_nbuckets)\ - map_init_(&(m)->base, initial_nbuckets) + ( ((m) != NULL) ? map_init_(&(m)->base, initial_nbuckets) : -1 ) #define map_deinit(m)\ - map_deinit_(&(m)->base) + do { if ((m) != NULL) { map_deinit_(&(m)->base); } } while (0) #define map_get(m, key)\ - ( (m)->ref = map_get_(&(m)->base, key) ) + ( ((m) != NULL) ? map_get_(&(m)->base, key) : NULL ) #define map_set(m, key, value)\ - ( (m)->tmp = (value),\ - map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp)) ) - + ( ((m) != NULL) ? ((m)->tmp = (value), map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp))) : -1 ) #define map_remove(m, key)\ - map_remove_(&(m)->base, key) + do { if ((m) != NULL) { map_remove_(&(m)->base, key); } } while (0) #define map_iter(m)\ @@ -56,7 +56,7 @@ typedef struct { #define map_next(m, iter)\ - map_next_(&(m)->base, iter) + ( ((m) != NULL) ? map_next_(&(m)->base, iter) : NULL ) int map_init_(map_base_t *m, unsigned initial_nbuckets); From dd4f31ca13f6515a537bf26a418902216991d8c4 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Mon, 8 Oct 2018 11:37:43 +0200 Subject: [PATCH 03/26] unsigned -> unsigned int. useless typedef removed. function argument type adjusted. --- src/map.c | 20 ++++++++++---------- src/map.h | 13 +++---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/map.c b/src/map.c index 584430c..2efbfaf 100644 --- a/src/map.c +++ b/src/map.c @@ -11,7 +11,7 @@ #include "map.h" struct map_node_t { - unsigned hash; + unsigned int hash; void *value; map_node_t *next; /* char key[]; */ @@ -19,8 +19,8 @@ struct map_node_t { }; -static unsigned map_hash(const char *str) { - unsigned hash = 5381; +static unsigned int map_hash(const char *str) { + unsigned int hash = 5381; while (*str) { hash = ((hash << 5) + hash) ^ *str++; } @@ -42,7 +42,7 @@ static map_node_t *map_newnode(const char *key, void *value, int vsize) { } -static int map_bucketidx(map_base_t *m, unsigned hash) { +static int map_bucketidx(map_base_t *m, unsigned int hash) { /* If the implementation is changed to allow a non-power-of-2 bucket count, * the line below should be changed to use mod instead of AND */ return hash & (m->nbuckets - 1); @@ -56,12 +56,12 @@ static void map_addnode(map_base_t *m, map_node_t *node) { } -static int map_resize(map_base_t *m, int nbuckets) { +static int map_resize(map_base_t *m, unsigned int nbuckets) { map_node_t *nodes, *node, *next; map_node_t **buckets; /* Chain all nodes together */ nodes = NULL; - unsigned i = m->nbuckets; + unsigned int i = m->nbuckets; while (i--) { node = (m->buckets)[i]; while (node) { @@ -93,7 +93,7 @@ static int map_resize(map_base_t *m, int nbuckets) { static map_node_t **map_getref(map_base_t *m, const char *key) { - unsigned hash = map_hash(key); + unsigned int hash = map_hash(key); if (m->nbuckets > 0) { map_node_t **next = &m->buckets[map_bucketidx(m, hash)]; while (*next) { @@ -107,7 +107,7 @@ static map_node_t **map_getref(map_base_t *m, const char *key) { } -int map_init_(map_base_t *m, unsigned initial_nbuckets) { +int map_init_(map_base_t *m, unsigned int initial_nbuckets) { // Clear the memory. memset(m, 0, sizeof(*m)); m->initialized = true; @@ -125,7 +125,7 @@ void map_deinit_(map_base_t *m) { return; if (!m->initialized) return; - unsigned i = m->nbuckets; + unsigned int i = m->nbuckets; while (i--) { map_node_t *node = m->buckets[i]; while (node) { @@ -164,7 +164,7 @@ int map_set_(map_base_t *m, const char *key, void *value, int vsize) { map_node_t *node = map_newnode(key, value, vsize); if (node == NULL) goto fail; if (m->nnodes >= m->nbuckets) { - int n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; + unsigned int n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; int err = map_resize(m, n); if (err) goto fail; } diff --git a/src/map.h b/src/map.h index d9a35ce..b4fc831 100644 --- a/src/map.h +++ b/src/map.h @@ -18,12 +18,12 @@ typedef struct map_node_t map_node_t; typedef struct { map_node_t **buckets; - unsigned nbuckets, nnodes; + unsigned int nbuckets, nnodes; bool initialized; } map_base_t; typedef struct { - unsigned bucketidx; + unsigned int bucketidx; map_node_t *node; } map_iter_t; @@ -59,7 +59,7 @@ typedef struct { ( ((m) != NULL) ? map_next_(&(m)->base, iter) : NULL ) -int map_init_(map_base_t *m, unsigned initial_nbuckets); +int map_init_(map_base_t *m, unsigned int initial_nbuckets); void map_deinit_(map_base_t *m); void *map_get_(map_base_t *m, const char *key); int map_set_(map_base_t *m, const char *key, void *value, int vsize); @@ -68,11 +68,4 @@ map_iter_t map_iter_(void); const char *map_next_(map_base_t *m, map_iter_t *iter); -typedef map_t(void*) map_void_t; -typedef map_t(char*) map_str_t; -typedef map_t(int) map_int_t; -typedef map_t(char) map_char_t; -typedef map_t(float) map_float_t; -typedef map_t(double) map_double_t; - #endif From c7e36a3251bc1c7efc93e0ab2fe9c171b2520548 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 23 Oct 2018 10:16:22 +0200 Subject: [PATCH 04/26] map_newnode() adjusted to be more readable (at cost of 2 additional call to malloc). indentation adjusted. --- src/map.c | 326 ++++++++++++++++++++++++++++-------------------------- src/map.h | 26 ++--- 2 files changed, 184 insertions(+), 168 deletions(-) diff --git a/src/map.c b/src/map.c index 2efbfaf..f01ccb6 100644 --- a/src/map.c +++ b/src/map.c @@ -8,214 +8,230 @@ #include #include #include + #include "map.h" struct map_node_t { - unsigned int hash; - void *value; - map_node_t *next; - /* char key[]; */ - /* char value[]; */ + unsigned int hash; + void *value; + char *key; + map_node_t *next; }; static unsigned int map_hash(const char *str) { - unsigned int hash = 5381; - while (*str) { - hash = ((hash << 5) + hash) ^ *str++; - } - return hash; + unsigned int hash = 5381; + while (*str) { + hash = ((hash << 5) + hash) ^ *str++; + } + return hash; } static map_node_t *map_newnode(const char *key, void *value, int vsize) { - int ksize = strlen(key) + 1; - if (ksize > PTRDIFF_MAX) return NULL; - int voffset = ksize + ((sizeof(void*) - ksize) % sizeof(void*)); - map_node_t *node = malloc(sizeof(*node) + voffset + vsize); - if (!node) return NULL; - memcpy(node + 1, key, ksize); - node->hash = map_hash(key); - node->value = ((char*) (node + 1)) + voffset; - memcpy(node->value, value, vsize); - return node; + map_node_t *node = malloc(sizeof(*node)); + if (!node) + return NULL; + node->hash = map_hash(key); + node->key = strdup(key); + if (node->key == NULL) { + free(node); + return NULL; + } + node->value = malloc(vsize); + if (node->value == NULL) { + free(node->key); + free(node); + return NULL; + } + memcpy(node->value, value, vsize); + return node; +} + + +static void map_deletenode(map_node_t *node) { + if (node == NULL) + return; + free(node->value); + free(node->key); + free(node); } static int map_bucketidx(map_base_t *m, unsigned int hash) { - /* If the implementation is changed to allow a non-power-of-2 bucket count, - * the line below should be changed to use mod instead of AND */ - return hash & (m->nbuckets - 1); + /* If the implementation is changed to allow a non-power-of-2 bucket count, + * the line below should be changed to use mod instead of AND */ + return hash & (m->nbuckets - 1); } static void map_addnode(map_base_t *m, map_node_t *node) { - int n = map_bucketidx(m, node->hash); - node->next = m->buckets[n]; - m->buckets[n] = node; + int n = map_bucketidx(m, node->hash); + node->next = m->buckets[n]; + m->buckets[n] = node; } static int map_resize(map_base_t *m, unsigned int nbuckets) { - map_node_t *nodes, *node, *next; - map_node_t **buckets; - /* Chain all nodes together */ - nodes = NULL; - unsigned int i = m->nbuckets; - while (i--) { - node = (m->buckets)[i]; - while (node) { - next = node->next; - node->next = nodes; - nodes = node; - node = next; - } - } - /* Reset buckets */ - buckets = realloc(m->buckets, sizeof(*m->buckets) * nbuckets); - if (buckets != NULL) { - m->buckets = buckets; - m->nbuckets = nbuckets; - } - if (m->buckets) { - memset(m->buckets, 0, sizeof(*m->buckets) * m->nbuckets); - /* Re-add nodes to buckets */ - node = nodes; - while (node) { - next = node->next; - map_addnode(m, node); - node = next; - } - } - /* Return error code if realloc() failed */ - return (buckets == NULL) ? -1 : 0; + map_node_t *nodes, *node, *next; + map_node_t **buckets; + /* Chain all nodes together */ + nodes = NULL; + unsigned int i = m->nbuckets; + while (i--) { + node = (m->buckets)[i]; + while (node) { + next = node->next; + node->next = nodes; + nodes = node; + node = next; + } + } + /* Reset buckets */ + buckets = realloc(m->buckets, sizeof(*m->buckets) * nbuckets); + if (buckets != NULL) { + m->buckets = buckets; + m->nbuckets = nbuckets; + } + if (m->buckets) { + memset(m->buckets, 0, sizeof(*m->buckets) * m->nbuckets); + /* Re-add nodes to buckets */ + node = nodes; + while (node) { + next = node->next; + map_addnode(m, node); + node = next; + } + } + /* Return error code if realloc() failed */ + return (buckets == NULL) ? -1 : 0; } static map_node_t **map_getref(map_base_t *m, const char *key) { - unsigned int hash = map_hash(key); - if (m->nbuckets > 0) { - map_node_t **next = &m->buckets[map_bucketidx(m, hash)]; - while (*next) { - if ((*next)->hash == hash && !strcmp((char*) (*next + 1), key)) { - return next; - } - next = &(*next)->next; - } - } - return NULL; + unsigned int hash = map_hash(key); + if (m->nbuckets > 0) { + map_node_t **next = &m->buckets[map_bucketidx(m, hash)]; + while (*next) { + if ((*next)->hash == hash && !strcmp((*next)->key, key)) { + return next; + } + next = &(*next)->next; + } + } + return NULL; } int map_init_(map_base_t *m, unsigned int initial_nbuckets) { - // Clear the memory. - memset(m, 0, sizeof(*m)); - m->initialized = true; - // Pre-initialize buckets array only if initial_nbuckets is a power of 2. - // Anyway, it is reallocated automatically when needed. - if ((initial_nbuckets > 0) && !(initial_nbuckets & (initial_nbuckets - 1))) - return map_resize(m, initial_nbuckets); - else - return 0; + // Clear the memory. + memset(m, 0, sizeof(*m)); + m->initialized = true; + // Pre-initialize buckets array only if initial_nbuckets is a power of 2. + // Anyway, it is reallocated automatically when needed. + if ((initial_nbuckets > 0) && !(initial_nbuckets & (initial_nbuckets - 1))) + return map_resize(m, initial_nbuckets); + else + return 0; } void map_deinit_(map_base_t *m) { - if (m == NULL) - return; - if (!m->initialized) - return; - unsigned int i = m->nbuckets; - while (i--) { - map_node_t *node = m->buckets[i]; - while (node) { - map_node_t *next = node->next; - free(node); - node = next; - } - } - free(m->buckets); - m->initialized = false; + if (m == NULL) + return; + if (!m->initialized) + return; + unsigned int i = m->nbuckets; + while (i--) { + map_node_t *node = m->buckets[i]; + while (node) { + map_node_t *next = node->next; + map_deletenode(node); + node = next; + } + } + free(m->buckets); + m->initialized = false; } void *map_get_(map_base_t *m, const char *key) { - if (m == NULL || key == NULL) - return NULL; - if (!m->initialized) - return NULL; - map_node_t **next = map_getref(m, key); - return next ? (*next)->value : NULL; + if (m == NULL || key == NULL) + return NULL; + if (!m->initialized) + return NULL; + map_node_t **next = map_getref(m, key); + return next ? (*next)->value : NULL; } int map_set_(map_base_t *m, const char *key, void *value, int vsize) { - if (m == NULL || key == NULL || value == NULL) - return -1; - if (!m->initialized) - return -1; - /* Find & replace existing node */ - map_node_t **next = map_getref(m, key); - if (next) { - memcpy((*next)->value, value, vsize); - return 0; - } - /* Add new node */ - map_node_t *node = map_newnode(key, value, vsize); - if (node == NULL) goto fail; - if (m->nnodes >= m->nbuckets) { - unsigned int n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; - int err = map_resize(m, n); - if (err) goto fail; - } - map_addnode(m, node); - m->nnodes++; - return 0; - fail: - if (node) free(node); - return -1; + if (m == NULL || key == NULL || value == NULL) + return -1; + if (!m->initialized) + return -1; + /* Find & replace existing node */ + map_node_t **next = map_getref(m, key); + if (next) { + memcpy((*next)->value, value, vsize); + return 0; + } + /* Add new node */ + map_node_t *node = map_newnode(key, value, vsize); + if (node == NULL) goto fail; + if (m->nnodes >= m->nbuckets) { + unsigned int n = (m->nbuckets > 0) ? (m->nbuckets << 1) : 1; + int err = map_resize(m, n); + if (err) goto fail; + } + map_addnode(m, node); + m->nnodes++; + return 0; + fail: + map_deletenode(node); + return -1; } void map_remove_(map_base_t *m, const char *key) { - if (m == NULL || key == NULL) - return; - if (!m->initialized) - return; - map_node_t **next = map_getref(m, key); - if (next) { - map_node_t *node = *next; - *next = (*next)->next; - free(node); - m->nnodes--; - } + if (m == NULL || key == NULL) + return; + if (!m->initialized) + return; + map_node_t **next = map_getref(m, key); + if (next) { + map_node_t *node = *next; + *next = (*next)->next; + map_deletenode(node); + m->nnodes--; + } } map_iter_t map_iter_(void) { - map_iter_t iter; - iter.bucketidx = -1; - iter.node = NULL; - return iter; + map_iter_t iter; + iter.bucketidx = -1; + iter.node = NULL; + return iter; } const char *map_next_(map_base_t *m, map_iter_t *iter) { - if (m == NULL || iter == NULL) - return NULL; - if (!m->initialized) - return NULL; - if (iter->node) { - iter->node = iter->node->next; - if (iter->node == NULL) goto nextBucket; - } else { - nextBucket: - do { - if (++iter->bucketidx >= m->nbuckets) { - return NULL; - } - iter->node = m->buckets[iter->bucketidx]; - } while (iter->node == NULL); - } - return (char*) (iter->node + 1); + if (m == NULL || iter == NULL) + return NULL; + if (!m->initialized) + return NULL; + if (iter->node) { + iter->node = iter->node->next; + if (iter->node == NULL) goto nextBucket; + } else { + nextBucket: + do { + if (++iter->bucketidx >= m->nbuckets) { + return NULL; + } + iter->node = m->buckets[iter->bucketidx]; + } while (iter->node == NULL); + } + return iter->node->key; } diff --git a/src/map.h b/src/map.h index b4fc831..ff7708a 100644 --- a/src/map.h +++ b/src/map.h @@ -17,46 +17,46 @@ struct map_node_t; typedef struct map_node_t map_node_t; typedef struct { - map_node_t **buckets; - unsigned int nbuckets, nnodes; - bool initialized; + map_node_t **buckets; + unsigned int nbuckets, nnodes; + bool initialized; } map_base_t; typedef struct { - unsigned int bucketidx; - map_node_t *node; + unsigned int bucketidx; + map_node_t *node; } map_iter_t; #define map_t(T)\ - struct { map_base_t base; T *ref; T tmp; } + struct { map_base_t base; T *ref; T tmp; } #define map_init(m, initial_nbuckets)\ - ( ((m) != NULL) ? map_init_(&(m)->base, initial_nbuckets) : -1 ) + ( ((m) != NULL) ? map_init_(&(m)->base, initial_nbuckets) : -1 ) #define map_deinit(m)\ - do { if ((m) != NULL) { map_deinit_(&(m)->base); } } while (0) + do { if ((m) != NULL) { map_deinit_(&(m)->base); } } while (0) #define map_get(m, key)\ - ( ((m) != NULL) ? map_get_(&(m)->base, key) : NULL ) + ( ((m) != NULL) ? map_get_(&(m)->base, key) : NULL ) #define map_set(m, key, value)\ - ( ((m) != NULL) ? ((m)->tmp = (value), map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp))) : -1 ) + ( ((m) != NULL) ? ((m)->tmp = (value), map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp))) : -1 ) #define map_remove(m, key)\ - do { if ((m) != NULL) { map_remove_(&(m)->base, key); } } while (0) + do { if ((m) != NULL) { map_remove_(&(m)->base, key); } } while (0) #define map_iter(m)\ - map_iter_() + map_iter_() #define map_next(m, iter)\ - ( ((m) != NULL) ? map_next_(&(m)->base, iter) : NULL ) + ( ((m) != NULL) ? map_next_(&(m)->base, iter) : NULL ) int map_init_(map_base_t *m, unsigned int initial_nbuckets); From 03d6724749836d8f6a5569c00120bf26803fe809 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 23 Oct 2018 10:25:57 +0200 Subject: [PATCH 05/26] added test --- src/test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test.c diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..4215ef9 --- /dev/null +++ b/src/test.c @@ -0,0 +1,25 @@ +#include "map.h" +#include +#include + +typedef map_t(int) map_int_t; + +int main() { + map_int_t *map = malloc(sizeof(*map)); + if (map == NULL) + return -1; + + const int value = 12; + const char key[] = "mykey"; + + map_init(map, 16); + map_set(map, key, value); + + int *value_get = map_get(map, key); + + printf("%i\n", *value_get); + + free(map); + + return 0; +} \ No newline at end of file From cd7515295962ea8fd1323d99a21d09d129febaa6 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 23 Oct 2018 10:30:03 +0200 Subject: [PATCH 06/26] test improved --- src/test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test.c b/src/test.c index 4215ef9..d9687cf 100644 --- a/src/test.c +++ b/src/test.c @@ -14,12 +14,13 @@ int main() { map_init(map, 16); map_set(map, key, value); - int *value_get = map_get(map, key); - printf("%i\n", *value_get); + if (value_get != NULL) + printf("%i\n", *value_get); + else + printf("Error\n"); free(map); - return 0; } \ No newline at end of file From 86aa6db34c716fb23bf104538a695005d6bb812b Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 23 Oct 2018 10:36:01 +0200 Subject: [PATCH 07/26] readme improved --- README.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7b73159..9d73c29 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # map A type-safe generic hashmap implementation for C. +Forked by [rxi/map](https://github.com/rxi/map), it adds the preallocation +of an arbitrary (power of 2) number of buckets for performance improvements. ## Installation The [map.c](src/map.c?raw=1) and [map.h](src/map.h?raw=1) files can be dropped @@ -43,17 +45,6 @@ map_deinit(&m); ## Types -map.h provides the following predefined map types: - -Contained Type | Type name -----------------|---------------------------------- -void* | map_void_t -char* | map_str_t -int | map_int_t -char | map_char_t -float | map_float_t -double | map_double_t - To define a new map type the `map_t()` macro should be used: ```c /* Creates the type uint_map_t for storing unsigned ints */ @@ -72,8 +63,9 @@ Creates a map struct for containing values of type `T`. typedef map_t(FILE*) fp_map_t; ``` -### map\_init(m) -Initialises the map, this must be called before the map can be used. +### map\_init(m, initial_nbuckets) +Initialises the map, this must be called before the map can be used. The parameter +`initial_nbuckets` sets the number of buckets to be pre-allocated. ### map\_deinit(m) Deinitialises the map, freeing the memory the map allocated during use; From 7ae8d43d213768f6ca5e1241b26e82d031f9279b Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Mon, 5 Nov 2018 09:20:38 +0100 Subject: [PATCH 08/26] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d73c29..5d949d1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # map A type-safe generic hashmap implementation for C. -Forked by [rxi/map](https://github.com/rxi/map), it adds the preallocation +Forked from [rxi/map](https://github.com/rxi/map), it adds the preallocation of an arbitrary (power of 2) number of buckets for performance improvements. ## Installation From 7e9108f83316e0f8b30d885afa22d0b3a4405fec Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 2 Jan 2019 15:45:18 +0100 Subject: [PATCH 09/26] Interface with original version restored New macro map_init_reserve() --- src/map.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/map.h b/src/map.h index ff7708a..ea8a7e3 100644 --- a/src/map.h +++ b/src/map.h @@ -31,30 +31,27 @@ typedef struct { #define map_t(T)\ struct { map_base_t base; T *ref; T tmp; } - -#define map_init(m, initial_nbuckets)\ +#define map_init_reserve(m, initial_nbuckets)\ ( ((m) != NULL) ? map_init_(&(m)->base, initial_nbuckets) : -1 ) +#define map_init(m, initial_nbuckets)\ + map_init_reserve(m, 0) #define map_deinit(m)\ do { if ((m) != NULL) { map_deinit_(&(m)->base); } } while (0) - #define map_get(m, key)\ ( ((m) != NULL) ? map_get_(&(m)->base, key) : NULL ) - #define map_set(m, key, value)\ ( ((m) != NULL) ? ((m)->tmp = (value), map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp))) : -1 ) #define map_remove(m, key)\ do { if ((m) != NULL) { map_remove_(&(m)->base, key); } } while (0) - #define map_iter(m)\ map_iter_() - #define map_next(m, iter)\ ( ((m) != NULL) ? map_next_(&(m)->base, iter) : NULL ) From f4eab84cf972415544a4d60cf0ea96668688494e Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 2 Jan 2019 15:45:44 +0100 Subject: [PATCH 10/26] Minor --- src/map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map.h b/src/map.h index ea8a7e3..3903ea1 100644 --- a/src/map.h +++ b/src/map.h @@ -34,7 +34,7 @@ typedef struct { #define map_init_reserve(m, initial_nbuckets)\ ( ((m) != NULL) ? map_init_(&(m)->base, initial_nbuckets) : -1 ) -#define map_init(m, initial_nbuckets)\ +#define map_init(m)\ map_init_reserve(m, 0) #define map_deinit(m)\ From 0cb55e682f6916504a56de67c4fc2500f965fe56 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 2 Jan 2019 15:47:29 +0100 Subject: [PATCH 11/26] Update README for new changes --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5d949d1..990f9ef 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ into an existing C project and compiled along with it. ## Usage -Before using a map it should first be initialised using the `map_init()` +Before using a map it should first be initialised using the `map_init_reserve()` function. The second argument is an integer with the number of buckets to be pre-allocated. If is not a power of 2 or 0, no pre-allocation is done. It can improve the speed but, @@ -17,7 +17,13 @@ on the other hand, could allocate useless space. ```c map_int_t m; unsigned initial_nbuckets = 128; -map_init(&m, initial_nbuckets); +map_init_reserve(&m, initial_nbuckets); +``` + +For no pre-allocation, the macro `map_init()` can be used as well. +```c +map_int_t m; +map_init(&m); ``` Values can added to a map using the `map_set()` function. From eea6b63e5852675cbaf44be476baa5531403f759 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 2 Jan 2019 17:06:58 +0100 Subject: [PATCH 12/26] test fixed. minor improvements. --- src/map.c | 5 +++-- src/map.h | 2 +- src/test.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/map.c b/src/map.c index f01ccb6..a13f20c 100644 --- a/src/map.c +++ b/src/map.c @@ -28,7 +28,7 @@ static unsigned int map_hash(const char *str) { } -static map_node_t *map_newnode(const char *key, void *value, int vsize) { +static map_node_t *map_newnode(const char *key, const void *value, int vsize) { map_node_t *node = malloc(sizeof(*node)); if (!node) return NULL; @@ -45,6 +45,7 @@ static map_node_t *map_newnode(const char *key, void *value, int vsize) { return NULL; } memcpy(node->value, value, vsize); + node->next = NULL; return node; } @@ -165,7 +166,7 @@ void *map_get_(map_base_t *m, const char *key) { } -int map_set_(map_base_t *m, const char *key, void *value, int vsize) { +int map_set_(map_base_t *m, const char *key, const void *value, int vsize) { if (m == NULL || key == NULL || value == NULL) return -1; if (!m->initialized) diff --git a/src/map.h b/src/map.h index 3903ea1..6074469 100644 --- a/src/map.h +++ b/src/map.h @@ -59,7 +59,7 @@ typedef struct { int map_init_(map_base_t *m, unsigned int initial_nbuckets); void map_deinit_(map_base_t *m); void *map_get_(map_base_t *m, const char *key); -int map_set_(map_base_t *m, const char *key, void *value, int vsize); +int map_set_(map_base_t *m, const char *key, const void *value, int vsize); void map_remove_(map_base_t *m, const char *key); map_iter_t map_iter_(void); const char *map_next_(map_base_t *m, map_iter_t *iter); diff --git a/src/test.c b/src/test.c index d9687cf..4249732 100644 --- a/src/test.c +++ b/src/test.c @@ -12,7 +12,7 @@ int main() { const int value = 12; const char key[] = "mykey"; - map_init(map, 16); + map_init_reserve(map, 16); map_set(map, key, value); int *value_get = map_get(map, key); From 42112c804cafe2e9d4361432e94ae804debd2b8e Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Thu, 3 Jan 2019 11:57:16 +0100 Subject: [PATCH 13/26] Updated README.md --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 990f9ef..d0e216b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # map A type-safe generic hashmap implementation for C. -Forked from [rxi/map](https://github.com/rxi/map), it adds the preallocation -of an arbitrary (power of 2) number of buckets for performance improvements. +Forked from [rxi/map](https://github.com/rxi/map), it adds the possibility to +pre-allocate an arbitrary (power of 2) number of buckets for performance +improvements. ## Installation The [map.c](src/map.c?raw=1) and [map.h](src/map.h?raw=1) files can be dropped @@ -9,8 +10,8 @@ into an existing C project and compiled along with it. ## Usage -Before using a map it should first be initialised using the `map_init_reserve()` -function. +Before using a map, it should first be initialised using the `map_init_reserve()` +macro. The second argument is an integer with the number of buckets to be pre-allocated. If is not a power of 2 or 0, no pre-allocation is done. It can improve the speed but, on the other hand, could allocate useless space. @@ -20,18 +21,18 @@ unsigned initial_nbuckets = 128; map_init_reserve(&m, initial_nbuckets); ``` -For no pre-allocation, the macro `map_init()` can be used as well. +It pre-allocation is not needed, the macro `map_init()` can be used as well. ```c map_int_t m; map_init(&m); ``` -Values can added to a map using the `map_set()` function. +Values can added to a map using the `map_set()` macro. ```c map_set(&m, "testkey", 123); ``` -To retrieve a value from a map, the `map_get()` function can be used. +To retrieve a value from a map, the `map_get()` macro can be used. `map_get()` will return a pointer to the key's value, or `NULL` if no mapping for that key exists. ```c @@ -43,7 +44,7 @@ if (val) { } ``` -When you are done with a map the `map_deinit()` function should be called on +When you are done with a map the `map_deinit()` macro should be called on it. This will free any memory the map allocated during use. ```c map_deinit(&m); From 85b5514ee587f94fab638ec1bf43cd0ec7dc4e17 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Thu, 7 Feb 2019 15:41:15 +0100 Subject: [PATCH 14/26] Minor fix --- src/map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map.h b/src/map.h index 6074469..867bece 100644 --- a/src/map.h +++ b/src/map.h @@ -41,7 +41,7 @@ typedef struct { do { if ((m) != NULL) { map_deinit_(&(m)->base); } } while (0) #define map_get(m, key)\ - ( ((m) != NULL) ? map_get_(&(m)->base, key) : NULL ) + ( ((m) != NULL) ? ((m)->ref = map_get_(&(m)->base, key)) : NULL ) #define map_set(m, key, value)\ ( ((m) != NULL) ? ((m)->tmp = (value), map_set_(&(m)->base, key, &(m)->tmp, sizeof((m)->tmp))) : -1 ) From 5a8d342aae112eca23bebd49dddab6998792587b Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Tue, 26 Mar 2019 12:12:21 +0100 Subject: [PATCH 15/26] to version 0.1.2 --- LICENSE | 2 +- package.json | 4 ++-- src/map.c | 1 + src/map.h | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 03b6555..7b0c6ea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2014 rxi - +Copyright (c) 2019 gcerretani Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/package.json b/package.json index 7b5115b..b717e47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "map", - "version": "0.1.0", - "repo": "rxi/map", + "version": "0.1.2", + "repo": "gcerretani/map", "description": "Type-safe generic hash map", "keywords": ["hashmap", "map", "table", "hashtable", "dict", "dictionary"], "license": "MIT", diff --git a/src/map.c b/src/map.c index a13f20c..0171a5c 100644 --- a/src/map.c +++ b/src/map.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 rxi + * Copyright (c) 2019 gcerretani * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See LICENSE for details. diff --git a/src/map.h b/src/map.h index 867bece..c7d1f1d 100644 --- a/src/map.h +++ b/src/map.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 rxi + * Copyright (c) 2019 gcerretani * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See LICENSE for details. @@ -11,7 +12,7 @@ #include #include -#define MAP_VERSION "0.1.1" +#define MAP_VERSION "0.1.2" struct map_node_t; typedef struct map_node_t map_node_t; From abd63a842d6c0a77f4b614b0f4db6e2adcc0a304 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 16 Oct 2019 17:59:41 +0200 Subject: [PATCH 16/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0e216b..ed0566e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # map A type-safe generic hashmap implementation for C. Forked from [rxi/map](https://github.com/rxi/map), it adds the possibility to -pre-allocate an arbitrary (power of 2) number of buckets for performance +reserve an arbitrary (power of 2) number of buckets for performance improvements. ## Installation From 6b90ee68f357a512730931d427a23f2f80fc7ad1 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 4 Dec 2019 15:07:56 +0100 Subject: [PATCH 17/26] added Makefile for tests --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2408df5 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +CC = gcc +CFLAGS = -fPIC -Wall -Wextra +LDFLAGS = -shared +RM = rm -f +NAME_LIB = map +TARGET_LIB = lib$(NAME_LIB).so + +SRCS = src/map.c +TEST_SRCS = src/test.c +TEST_OUTPUT = test +OBJS = $(SRCS:.c=.o) + +.PHONY: all +all: $(TARGET_LIB) + +$(TARGET_LIB): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ + +.PHONY: clean +clean: + -$(RM) $(TARGET_LIB) $(OBJS) $(TEST_OUTPUT) + +test: + -$(CC) $(TEST_SRCS) -l$(NAME_LIB) -o $(TEST_OUTPUT) -L. From 2031ac491f3a6e5dbe4b7c33f63c20946db30e9e Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 4 Dec 2019 15:10:29 +0100 Subject: [PATCH 18/26] Create ccpp.yml --- .github/workflows/ccpp.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/ccpp.yml diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 0000000..1242cc0 --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -0,0 +1,17 @@ +name: C/C++ CI + +on: [push] + +jobs: + build: + + runs-on: [ubuntu-latest] + + steps: + - uses: actions/checkout@v1 + - name: make + run: make + - name: make test + run: make test + - name: make clean + run: make clean From 89d757c1b801c3573b075147aa45893778275da4 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Thu, 5 Dec 2019 09:49:26 +0100 Subject: [PATCH 19/26] test improved --- src/test.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/test.c b/src/test.c index 4249732..8eb3349 100644 --- a/src/test.c +++ b/src/test.c @@ -5,22 +5,31 @@ typedef map_t(int) map_int_t; int main() { + int ret = 0; + map_int_t *map = malloc(sizeof(*map)); - if (map == NULL) - return -1; - + if (map == NULL) { + ret = 1; + goto quit; + } + const int value = 12; const char key[] = "mykey"; - + map_init_reserve(map, 16); map_set(map, key, value); - int *value_get = map_get(map, key); - - if (value_get != NULL) - printf("%i\n", *value_get); - else - printf("Error\n"); - + int *value_get = map_get(map, key); + + if (value_get == NULL) { + ret = 2; + goto quit; + } + + if (*value_get != value) { + ret = 3; + } + +quit: free(map); - return 0; -} \ No newline at end of file + return ret; +} From 72d0d06aab724cfce88e32aac00dee6032ffea19 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Thu, 5 Dec 2019 09:59:51 +0100 Subject: [PATCH 20/26] added run test on github action --- .github/workflows/ccpp.yml | 2 ++ Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 1242cc0..e61ea27 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -13,5 +13,7 @@ jobs: run: make - name: make test run: make test + - name: run test + run: test - name: make clean run: make clean diff --git a/Makefile b/Makefile index 2408df5..56293ad 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,4 @@ clean: -$(RM) $(TARGET_LIB) $(OBJS) $(TEST_OUTPUT) test: - -$(CC) $(TEST_SRCS) -l$(NAME_LIB) -o $(TEST_OUTPUT) -L. + -$(CC) $(TEST_SRCS) -l$(NAME_LIB) -Wl,-rpath,. -o $(TEST_OUTPUT) -L. From 0713d7225cdef8787edbe1ef50b505398fd0e721 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Thu, 5 Dec 2019 10:03:18 +0100 Subject: [PATCH 21/26] fixed call to test --- .github/workflows/ccpp.yml | 2 +- src/test.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index e61ea27..141f4e4 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -14,6 +14,6 @@ jobs: - name: make test run: make test - name: run test - run: test + run: ./test - name: make clean run: make clean diff --git a/src/test.c b/src/test.c index 8eb3349..924a50e 100644 --- a/src/test.c +++ b/src/test.c @@ -31,5 +31,7 @@ int main() { quit: free(map); + printf("%d\n", ret); + return ret; } From 3776edbc627b2abf8b064bb0c6136cfdfdc0937a Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 14 Sep 2022 12:26:07 +0200 Subject: [PATCH 22/26] fix test memory leak --- src/test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test.c b/src/test.c index 924a50e..ff8541b 100644 --- a/src/test.c +++ b/src/test.c @@ -27,9 +27,11 @@ int main() { if (*value_get != value) { ret = 3; + goto quit; } quit: + map_deinit(map); free(map); printf("%d\n", ret); From 7e6c1c33a875a0e96cba48ae062a6f8c270d19d1 Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 5 Oct 2022 10:17:58 +0200 Subject: [PATCH 23/26] Update LICENSE --- LICENSE | 1 - 1 file changed, 1 deletion(-) diff --git a/LICENSE b/LICENSE index 7b0c6ea..79502d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,4 @@ Copyright (c) 2014 rxi -Copyright (c) 2019 gcerretani Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From f1aca0e5565662994124102ba0c105712f4cbb5c Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 5 Oct 2022 10:21:38 +0200 Subject: [PATCH 24/26] Update map.h --- src/map.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/map.h b/src/map.h index c7d1f1d..945d2ba 100644 --- a/src/map.h +++ b/src/map.h @@ -1,6 +1,5 @@ /** * Copyright (c) 2014 rxi - * Copyright (c) 2019 gcerretani * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See LICENSE for details. From 168096ab3d72445a8c1ab10b8eba8f493f2feb6b Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 5 Oct 2022 10:21:50 +0200 Subject: [PATCH 25/26] Update map.c --- src/map.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/map.c b/src/map.c index 0171a5c..a13f20c 100644 --- a/src/map.c +++ b/src/map.c @@ -1,6 +1,5 @@ /** * Copyright (c) 2014 rxi - * Copyright (c) 2019 gcerretani * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See LICENSE for details. From ef9576f4f7e2ac92568790dc941b3f2daf6de93a Mon Sep 17 00:00:00 2001 From: Giovanni Cerretani Date: Wed, 5 Oct 2022 10:22:35 +0200 Subject: [PATCH 26/26] Update test.c --- src/test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test.c b/src/test.c index ff8541b..efe9a99 100644 --- a/src/test.c +++ b/src/test.c @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2019-2022 Giovanni Cerretani + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the MIT license. See LICENSE for details. + */ + #include "map.h" #include #include