diff --git a/pandas/_libs/include/pandas/vendored/klib/khash_python.h b/pandas/_libs/include/pandas/vendored/klib/khash_python.h index 5a933b45d9e21..8bb3f84369b0b 100644 --- a/pandas/_libs/include/pandas/vendored/klib/khash_python.h +++ b/pandas/_libs/include/pandas/vendored/klib/khash_python.h @@ -1,6 +1,9 @@ // Licence at LICENSES/KLIB_LICENSE +#pragma once + #include +#include #include typedef struct { @@ -12,20 +15,8 @@ typedef struct { double imag; } khcomplex128_t; -// khash should report usage to tracemalloc -#if PY_VERSION_HEX >= 0x03060000 -#include -#if PY_VERSION_HEX < 0x03070000 -#define PyTraceMalloc_Track _PyTraceMalloc_Track -#define PyTraceMalloc_Untrack _PyTraceMalloc_Untrack -#endif -#else -#define PyTraceMalloc_Track(...) -#define PyTraceMalloc_Untrack(...) -#endif - static const int KHASH_TRACE_DOMAIN = 424242; -void *traced_malloc(size_t size) { +static inline void *traced_malloc(size_t size) { void *ptr = malloc(size); if (ptr != NULL) { PyTraceMalloc_Track(KHASH_TRACE_DOMAIN, (uintptr_t)ptr, size); @@ -33,7 +24,7 @@ void *traced_malloc(size_t size) { return ptr; } -void *traced_calloc(size_t num, size_t size) { +static inline void *traced_calloc(size_t num, size_t size) { void *ptr = calloc(num, size); if (ptr != NULL) { PyTraceMalloc_Track(KHASH_TRACE_DOMAIN, (uintptr_t)ptr, num * size); @@ -41,7 +32,7 @@ void *traced_calloc(size_t num, size_t size) { return ptr; } -void *traced_realloc(void *old_ptr, size_t size) { +static inline void *traced_realloc(void *old_ptr, size_t size) { void *ptr = realloc(old_ptr, size); if (ptr != NULL) { if (old_ptr != ptr) { @@ -52,7 +43,7 @@ void *traced_realloc(void *old_ptr, size_t size) { return ptr; } -void traced_free(void *ptr) { +static inline void traced_free(void *ptr) { if (ptr != NULL) { PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)ptr); }