nostrdb: move everything to src

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2023-12-23 09:30:08 -08:00
committed by Daniel D’Aquino
parent 1fb88a912a
commit 1ffbd80c67
82 changed files with 34 additions and 82 deletions

33
nostrdb/src/util.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef NDB_UTIL_H
#define NDB_UTIL_H
static inline int min(int a, int b) {
return a < b ? a : b;
}
static inline int max(int a, int b) {
return a > b ? a : b;
}
static inline void* memdup(const void* src, size_t size) {
void* dest = malloc(size);
if (dest == NULL) {
return NULL; // Memory allocation failed
}
memcpy(dest, src, size);
return dest;
}
static inline char *strdupn(const char *src, size_t size) {
char* dest = malloc(size+1);
if (dest == NULL) {
return NULL; // Memory allocation failed
}
memcpy(dest, src, size);
dest[size] = '\0';
return dest;
}
#endif // NDB_UTIL_H