X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemory.h;fp=libmemcached%2Fmemory.h;h=3d5faf8a243fb4930e4fc79b0f7c9a0c435bdc3a;hb=69e4ae10dc2c3d30f74db2c7f18dee16a7cedaef;hp=e59eabbea9c21412d2c892e906746f1e50d72374;hpb=abe084a9695d9ac7c3670938f8126cbfc709f796;p=awesomized%2Flibmemcached diff --git a/libmemcached/memory.h b/libmemcached/memory.h index e59eabbe..3d5faf8a 100644 --- a/libmemcached/memory.h +++ b/libmemcached/memory.h @@ -38,6 +38,15 @@ #include +#ifdef __cplusplus +#include +#include +#include +#else +#include +#include +#endif + static inline void libmemcached_free(const memcached_st *self, void *mem) { if (self) @@ -46,7 +55,11 @@ static inline void libmemcached_free(const memcached_st *self, void *mem) } else if (mem) { +#ifdef __cplusplus + std::free(mem); +#else free(mem); +#endif } } @@ -57,7 +70,11 @@ static inline void *libmemcached_malloc(const memcached_st *self, const size_t s return self->allocators.malloc(self, size, self->allocators.context); } +#ifdef __cplusplus + return std::malloc(size); +#else return malloc(size); +#endif } #define libmemcached_xmalloc(__memcachd_st, __type) ((__type *)libmemcached_malloc((__memcachd_st), sizeof(__type))) @@ -68,7 +85,11 @@ static inline void *libmemcached_realloc(const memcached_st *self, void *mem, si return self->allocators.realloc(self, mem, nmemb * size, self->allocators.context); } +#ifdef __cplusplus + return std::realloc(mem, size); +#else return realloc(mem, size); +#endif } #define libmemcached_xrealloc(__memcachd_st, __mem, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), (__mem), (__nelem), sizeof(__type))) #define libmemcached_xvalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), NULL, (__nelem), sizeof(__type))) @@ -80,6 +101,10 @@ static inline void *libmemcached_calloc(const memcached_st *self, size_t nelem, return self->allocators.calloc(self, nelem, size, self->allocators.context); } +#ifdef __cplusplus + return std::calloc(nelem, size); +#else return calloc(nelem, size); +#endif } #define libmemcached_xcalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_calloc((__memcachd_st), (__nelem), sizeof(__type)))