libfreerdp-utils/memory: add a handy macro xnew; fix some code style.

This commit is contained in:
Vic Lee 2011-07-13 22:13:00 +08:00
parent e10a46ba65
commit ac1c74f859
2 changed files with 14 additions and 17 deletions

View File

@ -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 */

View File

@ -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);