From ac1c74f8597310c1d9cd85bfe531a1685d17bc7a Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Wed, 13 Jul 2011 22:13:00 +0800 Subject: [PATCH] libfreerdp-utils/memory: add a handy macro xnew; fix some code style. --- include/freerdp/utils/memory.h | 8 +++++--- libfreerdp-utils/memory.c | 23 +++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/freerdp/utils/memory.h b/include/freerdp/utils/memory.h index cb5cc9ddc..d475c8148 100644 --- a/include/freerdp/utils/memory.h +++ b/include/freerdp/utils/memory.h @@ -24,8 +24,10 @@ void* xmalloc(size_t size); void* xzalloc(size_t size); -void* xrealloc(void * ptr, size_t size); -void xfree(void * ptr); -char* xstrdup(const char * str); +void* xrealloc(void* ptr, size_t size); +void xfree(void* ptr); +char* xstrdup(const char* str); + +#define xnew(_type) (_type*)xzalloc(sizeof(_type)) #endif /* __MEMORY_UTILS_H */ diff --git a/libfreerdp-utils/memory.c b/libfreerdp-utils/memory.c index 148c316cd..f20c9d29d 100644 --- a/libfreerdp-utils/memory.c +++ b/libfreerdp-utils/memory.c @@ -28,10 +28,9 @@ * @param size */ -void * -xmalloc(size_t size) +void* xmalloc(size_t size) { - void * mem; + void* mem; if (size < 1) size = 1; @@ -49,10 +48,9 @@ xmalloc(size_t size) * @param size */ -void * -xzalloc(size_t size) +void* xzalloc(size_t size) { - void * mem; + void* mem; if (size < 1) size = 1; @@ -71,10 +69,9 @@ xzalloc(size_t size) * @param size */ -void * -xrealloc(void * ptr, size_t size) +void* xrealloc(void* ptr, size_t size) { - void * mem; + void* mem; if (size < 1) size = 1; @@ -92,8 +89,7 @@ xrealloc(void * ptr, size_t size) * @param mem */ -void -xfree(void * ptr) +void xfree(void* ptr) { if (ptr != NULL) free(ptr); @@ -105,10 +101,9 @@ xfree(void * ptr) * @return */ -char * -xstrdup(const char * str) +char* xstrdup(const char* str) { - char * mem; + char* mem; #ifdef _WIN32 mem = _strdup(str);