Use glib's malloc functions when compiled with LIBGTOP_USE_GLIB_MALLOC.
1999-10-24 Martin Baulig <martin@home-of-linux.org> * xmalloc.c: Use glib's malloc functions when compiled with LIBGTOP_USE_GLIB_MALLOC.
This commit is contained in:
committed by
Martin Baulig
parent
71e81ccad3
commit
eae892c9b1
@@ -1,7 +1,7 @@
|
|||||||
1999-10-24 Martin Baulig <martin@home-of-linux.org>
|
1999-10-24 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
* xmalloc.c: Use glib's malloc functions when compiled
|
* xmalloc.c: Use glib's malloc functions when compiled
|
||||||
with LIBGTOP_ENABLE_DEBUG.
|
with LIBGTOP_USE_GLIB_MALLOC.
|
||||||
|
|
||||||
* xmalloc_suid.c: New file.
|
* xmalloc_suid.c: New file.
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <glibtop/xmalloc.h>
|
#include <glibtop/xmalloc.h>
|
||||||
|
|
||||||
#if LIBGTOP_ENABLE_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
void *
|
void *
|
||||||
glibtop_malloc_r (glibtop *server, size_t size)
|
glibtop_malloc_r (glibtop *server, size_t size)
|
||||||
{
|
{
|
||||||
#if LIBGTOP_ENABLE_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
return g_malloc0 (size);
|
return g_malloc0 (size);
|
||||||
#else
|
#else
|
||||||
void *buf = malloc (size);
|
void *buf = malloc (size);
|
||||||
@@ -47,7 +47,7 @@ glibtop_malloc_r (glibtop *server, size_t size)
|
|||||||
void *
|
void *
|
||||||
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
|
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
#if LIBGTOP_ENABLE_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
return g_malloc0 (size * nmemb);
|
return g_malloc0 (size * nmemb);
|
||||||
#else
|
#else
|
||||||
void *buf = calloc (nmemb, size);
|
void *buf = calloc (nmemb, size);
|
||||||
@@ -63,7 +63,7 @@ glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
|
|||||||
void *
|
void *
|
||||||
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
|
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
#if LIBGTOP_ENABLE_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
return g_realloc (ptr, size);
|
return g_realloc (ptr, size);
|
||||||
#else
|
#else
|
||||||
void *buf = realloc (ptr, size);
|
void *buf = realloc (ptr, size);
|
||||||
@@ -78,7 +78,7 @@ glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
|
|||||||
char *
|
char *
|
||||||
glibtop_strdup_r (glibtop *server, const char *string)
|
glibtop_strdup_r (glibtop *server, const char *string)
|
||||||
{
|
{
|
||||||
#if LIBGTOP_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
return g_strdup (string);
|
return g_strdup (string);
|
||||||
#else
|
#else
|
||||||
return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
|
return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
|
||||||
@@ -88,7 +88,7 @@ glibtop_strdup_r (glibtop *server, const char *string)
|
|||||||
void
|
void
|
||||||
glibtop_free_r (glibtop *server, const void *ptr)
|
glibtop_free_r (glibtop *server, const void *ptr)
|
||||||
{
|
{
|
||||||
#if LIBGTOP_DEBUG
|
#ifdef LIBGTOP_USE_GLIB_MALLOC
|
||||||
g_free (ptr);
|
g_free (ptr);
|
||||||
#else
|
#else
|
||||||
if (ptr) free ((void *) ptr);
|
if (ptr) free ((void *) ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user