- replace all the xmalloc crap by glib memory management functions

This commit is contained in:
Bastien Nocera
2003-10-20 13:55:44 +00:00
parent af8478ca5f
commit ba36a20cb8
60 changed files with 209 additions and 951 deletions

View File

@@ -1,3 +1,11 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* ppp.c: (get_ISDN_stats):
* procargs.c: (glibtop_get_proc_args_s):
* proclist.c: (glibtop_get_proclist_s):
* procmap.c: (glibtop_get_proc_map_s):
replace all the xmalloc crap by glib memory management functions
2001-10-17 Abel Cheung <maddog@linux.org.hk>
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.

View File

@@ -55,17 +55,16 @@ get_ISDN_stats (glibtop *server, int *in, int *out)
*in = *out = 0;
isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
sizeof (unsigned long));
isdn_stats = g_malloc (ISDN_MAX_CHANNELS * 2 * sizeof (unsigned long));
fd = open ("/dev/isdninfo", O_RDONLY);
if (fd < 0) {
glibtop_free_r (server, isdn_stats);
g_free (isdn_stats);
return FALSE;
}
if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
glibtop_free_r (server, isdn_stats);
g_free (isdn_stats);
close (fd);
return FALSE;
@@ -75,7 +74,7 @@ get_ISDN_stats (glibtop *server, int *in, int *out)
*in += *ptr++; *out += *ptr++;
}
glibtop_free_r (server, isdn_stats);
g_free (isdn_stats);
close (fd);
return TRUE;

View File

@@ -57,13 +57,13 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
if (cmdline < 0) return NULL;
if (max_len) {
retval = glibtop_malloc_r (server, max_len+1);
retval = g_malloc (server, max_len+1);
len = read (cmdline, retval, max_len);
close (cmdline);
if (len < 0) {
glibtop_free_r (server, retval);
g_free (retval);
return NULL;
}
@@ -79,14 +79,14 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
len = read (cmdline, buffer, BUFSIZ-1);
if (len < 0) {
close (cmdline);
glibtop_free_r (server, retval);
g_free (retval);
return NULL;
}
if (len == 0)
break;
retval = glibtop_realloc_r (server, retval, total+len+1);
retval = g_realloc (retval, total+len+1);
memcpy (retval+total, buffer, len);
*(retval+total+len) = 0;
total += len;

View File

@@ -171,15 +171,14 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
* full, we copy it to the pids_chain. */
if (count >= BLOCK_COUNT) {
/* The following call to glibtop_realloc will be
* equivalent to glibtop_malloc () if `pids_chain' is
/* The following call to g_realloc will be
* equivalent to g_malloc () if `pids_chain' is
* NULL. We just calculate the new size and copy `pids'
* to the beginning of the newly allocated block. */
new_size = pids_size + BLOCK_SIZE;
pids_chain = glibtop_realloc_r
(server, pids_chain, new_size);
pids_chain = g_realloc (pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);
@@ -204,14 +203,14 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
if (!count) return NULL;
/* The following call to glibtop_realloc will be equivalent to
* glibtop_malloc if pids_chain is NULL. We just calculate the
/* The following call to g_realloc will be equivalent to
* g_malloc if pids_chain is NULL. We just calculate the
* new size and copy pids to the beginning of the newly allocated
* block. */
new_size = pids_size + count * sizeof (unsigned);
pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
pids_chain = g_realloc (pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));

View File

@@ -107,7 +107,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
size = (n+1) * sizeof (glibtop_map_entry);
entry_list = glibtop_realloc_r (server, entry_list, size);
entry_list = g_realloc (entry_list, size);
memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry));