Skip to content

Commit d2a2ba1

Browse files
Removed cleanup.h dependency on private.h to match upstream.
Removed __libnvme_free from private.h. It was only used by fabrics, which isn't supported on Windows, and in cleanup.h. Removed __libnvme_free implementation from util.c Directly calling aligned_free instead. This allows us to get rid of the private.h include in cleanup.h, better matching the recent upstream refactoring.
1 parent c57b385 commit d2a2ba1

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

libnvme/src/nvme/cleanup.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#include <stdlib.h>
66

7-
#include "private.h" /* for __libnvme_free */
8-
97
#define __cleanup(fn) __attribute__((cleanup(fn)))
108

119
#define DECLARE_CLEANUP_FUNC(name, type) \
@@ -26,7 +24,7 @@ static inline void freep(void *p)
2624

2725
static inline void nvme_freep(void *p)
2826
{
29-
__libnvme_free(*(void **)p);
27+
aligned_free(*(void **)p);
3028
}
3129
#define __cleanup_nvme_free __cleanup(nvme_freep)
3230

libnvme/src/nvme/fabrics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ static int nvme_discovery_log(libnvme_ctrl_t ctrl,
14151415
if (numrec == 0)
14161416
break;
14171417

1418-
__libnvme_free(log);
1418+
free(log);
14191419
entries_size = sizeof(*log->entries) * numrec;
14201420
log = __libnvme_alloc(sizeof(*log) + entries_size);
14211421
if (!log) {
@@ -1472,7 +1472,7 @@ static int nvme_discovery_log(libnvme_ctrl_t ctrl,
14721472
}
14731473

14741474
out_free_log:
1475-
__libnvme_free(log);
1475+
free(log);
14761476
return err;
14771477
}
14781478

@@ -1784,7 +1784,7 @@ static const char *dctype_str[] = {
17841784
*/
17851785
static int nvme_fetch_cntrltype_dctype_from_id(libnvme_ctrl_t c)
17861786
{
1787-
__cleanup_nvme_free struct nvme_id_ctrl *id = NULL;
1787+
__cleanup_free struct nvme_id_ctrl *id = NULL;
17881788
int ret;
17891789

17901790
id = __libnvme_alloc(sizeof(*id));
@@ -2255,7 +2255,7 @@ static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx,
22552255
struct libnvmf_context *fctx, libnvme_host_t h,
22562256
struct libnvme_ctrl **ctrl)
22572257
{
2258-
__cleanup_nvme_free struct nvme_id_ctrl *id = NULL;
2258+
__cleanup_free struct nvme_id_ctrl *id = NULL;
22592259
struct libnvme_ctrl *c;
22602260
int ret;
22612261

libnvme/src/nvme/private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,6 @@ void *__libnvme_alloc(size_t len);
380380

381381
void *__libnvme_realloc(void *p, size_t len);
382382

383-
void __libnvme_free(void *p);
384-
385383
void nvme_deconfigure_ctrl(struct libnvme_ctrl *c);
386384

387385
struct libnvme_host *libnvme_lookup_host(struct libnvme_global_ctx *ctx,

libnvme/src/nvme/util.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,17 +1028,12 @@ void *__libnvme_realloc(void *p, size_t len)
10281028

10291029
if (p && result) {
10301030
memcpy(result, p, min(old_len, len));
1031-
__libnvme_free(p);
1031+
aligned_free(p);
10321032
}
10331033

10341034
return result;
10351035
}
10361036

1037-
void __libnvme_free(void *p)
1038-
{
1039-
aligned_free(p);
1040-
}
1041-
10421037
#ifdef CONFIG_FABRICS
10431038
const struct ifaddrs *libnvme_getifaddrs(struct libnvme_global_ctx *ctx)
10441039
{

0 commit comments

Comments
 (0)