- replace all the xmalloc crap by glib memory management functions
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2003-10-20 Bastien Nocera <hadess@hadess.net>
|
||||
|
||||
* 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.
|
||||
|
@@ -61,7 +61,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
break;
|
||||
if(max_len)
|
||||
{
|
||||
ret = glibtop_malloc_r(server, max_len + 1);
|
||||
ret = g_malloc(server, max_len + 1);
|
||||
if(max_len < len)
|
||||
len = max_len;
|
||||
memcpy(ret, pinfo.pr_psargs, len);
|
||||
@@ -69,7 +69,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = glibtop_malloc_r(server, len + 1);
|
||||
ret = g_malloc(server, len + 1);
|
||||
memcpy(ret, pinfo.pr_psargs, len);
|
||||
ret[len] = 0;
|
||||
|
||||
|
@@ -97,7 +97,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
if(s_stat(buffer, &statb) < 0)
|
||||
return NULL;
|
||||
}
|
||||
if(!(pids_chain = glibtop_malloc(sizeof(unsigned))))
|
||||
if(!(pids_chain = g_malloc(sizeof(unsigned))))
|
||||
return NULL;
|
||||
*pids_chain = pid;
|
||||
return pids_chain;
|
||||
@@ -189,15 +189,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);
|
||||
|
||||
@@ -222,14 +221,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));
|
||||
|
||||
|
@@ -121,7 +121,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
if(!(entry = glibtop_malloc_r(server,
|
||||
if(!(entry = g_malloc(server,
|
||||
nmaps * sizeof(glibtop_map_entry))))
|
||||
return NULL;
|
||||
buf->number = nmaps;
|
||||
|
Reference in New Issue
Block a user