summaryrefslogtreecommitdiffstats
path: root/src/nvme/util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:06:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:06:50 +0000
commitc662bc3e81d6cc7c9265ea9c58b8d1dbf66245ea (patch)
tree6a0ebdb4cb3c7b76c824f021d9f3624d16037457 /src/nvme/util.c
parentAdding upstream version 1.8. (diff)
downloadlibnvme-c662bc3e81d6cc7c9265ea9c58b8d1dbf66245ea.tar.xz
libnvme-c662bc3e81d6cc7c9265ea9c58b8d1dbf66245ea.zip
Adding upstream version 1.9.upstream/1.9upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/nvme/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nvme/util.c b/src/nvme/util.c
index f091da7..7404509 100644
--- a/src/nvme/util.c
+++ b/src/nvme/util.c
@@ -12,6 +12,7 @@
#include <stdbool.h>
#include <string.h>
#include <errno.h>
+#include <malloc.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -619,6 +620,7 @@ static const char * const libnvme_status[] = {
[ENVME_CONNECT_OPNOTSUPP] = "not supported",
[ENVME_CONNECT_CONNREFUSED] = "connection refused",
[ENVME_CONNECT_ADDRNOTAVAIL] = "cannot assign requested address",
+ [ENVME_CONNECT_IGNORED] = "connection ignored",
};
const char *nvme_errno_to_string(int status)
@@ -1135,3 +1137,17 @@ void *__nvme_alloc(size_t len)
memset(p, 0, _len);
return p;
}
+
+void *__nvme_realloc(void *p, size_t len)
+{
+ size_t old_len = malloc_usable_size(p);
+
+ void *result = __nvme_alloc(len);
+
+ if (p) {
+ memcpy(result, p, min(old_len, len));
+ free(p);
+ }
+
+ return result;
+}