diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-09-13 09:38:07 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-09-13 09:38:07 +0000 |
commit | fb355e4200fcf98f36a4f3e1fbeb1e16b4761ee6 (patch) | |
tree | bf78792e9206e121607ad786432c0b60bbdcdc72 /src/libdcache/dcache_add.c | |
parent | 45c04a53fb9fbefe4dd86514c7563b4af1961dfb (diff) | |
download | shibari-fb355e4200fcf98f36a4f3e1fbeb1e16b4761ee6.tar.xz |
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libdcache/dcache_add.c')
-rw-r--r-- | src/libdcache/dcache_add.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libdcache/dcache_add.c b/src/libdcache/dcache_add.c new file mode 100644 index 0000000..82f1ef4 --- /dev/null +++ b/src/libdcache/dcache_add.c @@ -0,0 +1,27 @@ +/* ISC license. */ + +#include <stdint.h> +#include <string.h> + +#include <shibari/dcache.h> +#include "dcache-internal.h" + +#include <skalibs/posixishard.h> + +int dcache_add (dcache *z, char const *q, uint16_t qlen, uint16_t qtype, char const *data, uint16_t datalen, tai const *entry, tai const *expire) +{ + uint32_t i ; + dcache_node *node ; + if (!dcache_node_new(z, &i, q, qlen, qtype, datalen)) return 0 ; + node = DNODE(z, i) ; + node->entry = *entry ; + node->expire = *expire ; + memcpy(node->sa.s + node->sa.len, data, datalen) ; + node->sa.len += datalen ; + if (!dcache_node_add(z, i)) + { + dcache_node_free(node) ; + return 0 ; + } + return 1 ; +} |