nostrdb: pull latest, adding flatcc and lmdb
This commit is contained in:
33
nostrdb/util.h
Normal file
33
nostrdb/util.h
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user