- 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,19 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* RELNOTES-0.25: removed
* RELNOTES-1.0: removed
* RELNOTES-1.0.x: removed
* RELNOTES-1.1.x: removed
* include/glibtop/Makefile.am:
* include/glibtop/xmalloc.h: removed xmalloc.h
* lib/command.c: (glibtop_call_l):
* lib/init.c: (_init_server):
* lib/inodedb.c: (glibtop_inodedb_open_s),
(glibtop_inodedb_close_s):
* lib/read_data.c: (glibtop_read_data_l):
* lib/xmalloc.c: removed xmalloc.h
replace all the xmalloc crap by glib memory management functions
2003-10-20 Bastien Nocera <hadess@hadess.net> 2003-10-20 Bastien Nocera <hadess@hadess.net>
* lib/Makefile.am: * lib/Makefile.am:
@@ -977,7 +993,7 @@
* include/glibtop/command.h (glibtop_call): Third argument is * include/glibtop/command.h (glibtop_call): Third argument is
now `const void *'. now `const void *'.
* include/glibtop/xmalloc.h (glibtop_free): Now taking a * include/glibtop/xmalloc.h (g_free): Now taking a
`const void *'. `const void *'.
1998-08-25 Martin Baulig <martin@home-of-linux.org> 1998-08-25 Martin Baulig <martin@home-of-linux.org>
@@ -1563,7 +1579,7 @@
* glibtop.h (_glibtop): New field `server_port'. * glibtop.h (_glibtop): New field `server_port'.
* lib/xmalloc.c (glibtop_strdup_r): New function. * lib/xmalloc.c (g_strdup): New function.
* lib/gnuclient.c: Removed. * lib/gnuclient.c: Removed.

View File

@@ -1,146 +0,0 @@
RELEASE NOTES FOR LIBGTOP 0.25 STABLE
=====================================
OVERVIEW
--------
LibGTop is a library that read information about processes and the running
systems. This information include:
General System Information
cpu - CPU Usage
mem - Memory Usage
swap - Swap Usage (including paging activity)
loadavg - Load average (including nr_running, nr_tasks, last_pid)
uptime - Uptime and Idle time, can be calculated from CPU usage
SYS V IPC Limits:
shm_limits - Shared Memory Limits
msg_limits - Message Queue Limits
sem_limits - Semaphore Set Limits
Process List:
proclist - List of processes
Process information:
proc_state - cmd, state, uid, gid
proc_uid - uid,euid,gid,egid,pid,ppid,pgrp
session,tty,tpgid,priority,nice
proc_mem - size,vsize,resident,share,rss,rss_rlim
proc_time - start_time,rtime,utime,stime,cutime,cstime
timeout,it_real_value,frequency
proc_signal - signal,blocked,sigignore,sigcatch
proc_kernel - k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt
kstk_esp,kstk_eip,nwchan,wchan
proc_segment - text_rss,shlib_rss,data_rss,stack_rss,dirty_size
start_code,end_code,start_stack
Process maps:
proc_map - Process map (/proc/<pid>/maps under Linux)
File system usage:
mountlist - List of currently mounted filesystems
fsusage - File system usage
PORTABILITY:
-----------
LibGtop is designed to be as portable as possible. None of the functions
and retrieved information should be specific to a specific operating
system. So you only need to port the system dependent part of the library
to a new system and all application programs can then use libgtop on this
new system.
CLIENT/SERVER MODEL:
-------------------
Some systems like DEC OSF/1 or BSD require special priviledges for the calling
proces to fetch the required information (SUID root/SGID kmem). To solve this
problem, I designed a client/server model which makes a call to a SUID/SGID
server which fetches the required information whenever it is required. This
server is only called for features that really require priviledges, otherwise
the sysdeps code is called directory (every user can get the CPU usage on
DEC OSF/1, but only root can get information about processes other than the
current one).
There is also some kind of daemon which can be used to fetch information from
remote systems (still experimental). This daemon normally runs as nobody and
calls the SUID/SGID itself when needed.
GNOME APPLETS:
--------------
There are some applets and applications which already use LibGTop. They can
be found in the `libgtop-apps' module in the GNOME CVS tree:
* Applets: cpuload, cpumemusage - they need LibGTop to get their information
on all systems other than Linux.
* Applets: diskusage - just uses the mountlist/fsusage features of LibGTop,
the one in gnome-core also works on other systems.
* Applets: multiload - I enhanced the cpuload applet a little bit, it is
now a multi applet and can display CPU, Memory and
Swap usages.
GTOP:
----
This cool GNOME app has been ported to use LibGTop. It can be found in
`libgtop-apps/gtop' in the GNOME CVS tree.
You can now use nearly the full functionality of GTop on FreeBSD !
PLATTFORM SPECIFIC NOTES FOR LINUX:
==================================
Under Linux, LibGTop should work without problems and read everything
from /proc.
There is also an experimental kernel interface to read this information
directly from the kernel with a system call - but this is still experimental
and not well tested while I made this release.
PLATTFORM SPECIFIC NOTES FOR FREEBSD:
====================================
LibGTop should now work under FreeBSD and give you the full functionality
of GTop.
There are a few caveats:
* You need to manually make the `$(prefix)/bin/libgtop_server' SGID to kmem
after installation and mount the /proc filesystem of FreeBSD
(/proc/<pid>/mem is used withing kvm_uread ()).
* To get the filenames of the process maps displayed in GTop, you need to
configure with the `--with-libgtop-inodedb' option (you need GDBM for this
to work).
* You have then to create an inode database which is used to look up to
filenames. This is done using the `mkinodedb' program which comes along
with libgtop.
See the file src/inodedb/README for details:
The `mkinodedb' program which is build in this directory takes two
command line arguments: the full pathname of the database to be created
and the name of a configuration file consisting of directory and file names
each on a line by itself - see `/etc/ld.so.conf' for an example.
Putting a directory name in this file means all regular files found in this
directory are included in the database, but it will not recursively descend
into subdirectories (for instance, we want everythink in `/usr/lib' but not
every single file in `/usr/lib/sgml'). You can also use filenames to include
a single file.
Have fun,
Martin <martin@home-of-linux.org>

View File

@@ -1,163 +0,0 @@
RELEASE NOTES FOR LIBGTOP 1.0 STABLE
====================================
OVERVIEW
--------
LibGTop is a library that read information about processes and the
running systems. This information include:
General System Information:
cpu - CPU Usage
mem - Memory Usage
swap - Swap Usage (including paging activity)
loadavg - Load average (including nr_running, nr_tasks, last_pid)
uptime - Uptime and Idle time, can be calculated from CPU usage
SYS V IPC Limits:
shm_limits - Shared Memory Limits
msg_limits - Message Queue Limits
sem_limits - Semaphore Set Limits
Network:
netload - Network load
ppp - PPP statistics
Process List:
proclist - List of processes
Process information:
proc_state - cmd, state, uid, gid
proc_uid - uid,euid,gid,egid,pid,ppid,pgrp
session,tty,tpgid,priority,nice
proc_mem - size,vsize,resident,share,rss,rss_rlim
proc_time - start_time,rtime,utime,stime,cutime,cstime
timeout,it_real_value,frequency
proc_signal - signal,blocked,sigignore,sigcatch
proc_kernel - k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt
kstk_esp,kstk_eip,nwchan,wchan
proc_segment - text_rss,shlib_rss,data_rss,stack_rss,dirty_size
start_code,end_code,start_stack
Process maps:
proc_args - Command line arguments
proc_map - Process map (/proc/<pid>/maps under Linux)
File system usage:
mountlist - List of currently mounted filesystems
fsusage - File system usage
PORTABILITY:
-----------
LibGTop is designed to be as portable as possible. None of the
functions and retrieved information should be specific to a specific
operating system. So you only need to port the system dependent part
of the library to a new system and all application programs can then
use libgtop on this new system.
CLIENT/SERVER MODEL:
-------------------
Some systems like DEC OSF/1 or BSD require special privileges for the
calling process to fetch the required information (SUID root/SGID
kmem). To solve this problem, I designed a client/server model which
makes a call to a SUID/SGID server which fetches the required
information whenever it is required. This server is only called for
features that really require privileges, otherwise the sysdeps code
is called directory (every user can get the CPU usage on DEC OSF/1,
but only root can get information about processes other than the
current one).
There is also some kind of daemon which can be used to fetch
information from remote systems (still experimental). This daemon
normally runs as nobody and calls the SUID/SGID itself when needed.
LIBGTOP AND GNOME:
-----------------
LibGTop is currently used in various places in the GNOME Project,
for instance in some of the applets in gnome-core and - of cause -
this ultra-cool application called GTop ...
Although LibGTop is not specific to GNOME and under GPL license, I
spent most my time during the last months to work in the GNOME project
so this is the primary use for LibGTop (and currently the only one).
However, you can also give its configure.in script the `--without-gnome'
parameter and then use it fully without GNOME in your own applications.
LIBGTOP AND GNOME - PART II:
---------------------------
LibGTop was tested with FreeBSD 3.0 but it should also work with
FreeBSD 2.2.7, NetBSD and OpenBSD.
Currently my primary aim is to help the GNOME people with our 1.0 release
so I won't have much time to test it with any other system than Linux.
However, I consider FreeBSD, NetBSD and OpenBSD as supported systems for
LibGTop and whenever I get bug reports I will do my best to fix them as
quickly as possible.
PLATFORM SPECIFIC NOTES FOR LINUX:
==================================
Under Linux, LibGTop should work without problems and read everything
from /proc.
LibGTop 0.25 also had an experimental kernel interface to read this
information directly from the kernel with a system call - but I have
currently dropped support for this as I am too busy with GNOME
development to keep current with kernel hacking.
PLATFORM SPECIFIC NOTES FOR SOLARIS:
====================================
Since so many people were asking me about this:
LibGTop currently does not have any support for Solaris, and it will
never have until some volunteer writes the code for it. I can't do this
myself since I do not have any machine to test it on.
PLATFORM SPECIFIC NOTES FOR BSD:
=================================
There are a few caveats:
* You need to manually make the `$(prefix)/bin/libgtop_server' SGID to
kmem after installation and mount the /proc file system of FreeBSD
(/proc/<pid>/mem is used within kvm_uread ()).
* To get the filenames of the process maps displayed in GTop, you need
to configure with the `--with-libgtop-inodedb' option (you need GDBM
for this to work).
You have then to create an inode database which is used to look up
filenames. This is done using the `mkinodedb' program which comes
along with libgtop.
See the file src/inodedb/README for details:
The `mkinodedb' program which is build in this directory takes two
command line arguments: the full pathname of the database to be
created and the name of a configuration file consisting of directory
and file names each on a line by itself - see `/etc/ld.so.conf' for
an example.
Putting a directory name in this file means all regular files found
in this directory are included in the database, but it will not
recursively descend into subdirectories (for instance, we want
everything in `/usr/lib' but not every single file in `/usr/lib/sgml').
You can also use filenames to include a single file.
Have fun,
Martin <martin@home-of-linux.org>

View File

@@ -1,172 +0,0 @@
RELEASE NOTES FOR LIBGTOP 1.0.7
===============================
OVERVIEW
--------
LibGTop is a library that read information about processes and the
running systems. This information include:
General System Information:
cpu - CPU Usage
mem - Memory Usage
swap - Swap Usage (including paging activity)
loadavg - Load average (including nr_running, nr_tasks, last_pid)
uptime - Uptime and Idle time, can be calculated from CPU usage
SYS V IPC Limits:
shm_limits - Shared Memory Limits
msg_limits - Message Queue Limits
sem_limits - Semaphore Set Limits
Network:
netload - Network load
ppp - PPP statistics
Process List:
proclist - List of processes
Process information:
proc_state - cmd, state, uid, gid
proc_uid - uid,euid,gid,egid,pid,ppid,pgrp
session,tty,tpgid,priority,nice
proc_mem - size,vsize,resident,share,rss,rss_rlim
proc_time - start_time,rtime,utime,stime,cutime,cstime
timeout,it_real_value,frequency
proc_signal - signal,blocked,sigignore,sigcatch
proc_kernel - k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt
kstk_esp,kstk_eip,nwchan,wchan
proc_segment - text_rss,shlib_rss,data_rss,stack_rss,dirty_size
start_code,end_code,start_stack
Process maps:
proc_args - Command line arguments
proc_map - Process map (/proc/<pid>/maps under Linux)
File system usage:
mountlist - List of currently mounted filesystems
fsusage - File system usage
PORTABILITY:
-----------
LibGTop is designed to be as portable as possible. None of the
functions and retrieved information should be specific to a specific
operating system. So you only need to port the system dependent part
of the library to a new system and all application programs can then
use libgtop on this new system.
CLIENT/SERVER MODEL:
-------------------
Some systems like DEC OSF/1 or BSD require special privileges for the
calling process to fetch the required information (SUID root/SGID
kmem). To solve this problem, I designed a client/server model which
makes a call to a SUID/SGID server which fetches the required
information whenever it is required. This server is only called for
features that really require privileges, otherwise the sysdeps code
is called directory (every user can get the CPU usage on DEC OSF/1,
but only root can get information about processes other than the
current one).
There is also some kind of daemon which can be used to fetch
information from remote systems (still experimental). This daemon
normally runs as nobody and calls the SUID/SGID itself when needed.
LIBGTOP AND GNOME:
-----------------
Although LibGTop is part of the GNOME desktop environment, its main
interface is totally independent from any particular desktop environment,
so you can also use it as a standalone library in any piece of GPLed
software which makes it also a valuable part of the GNU project.
LibGTop is currently used in various places in the GNOME Project,
for instance in some of the applets in gnome-core and - of cause -
this ultra-cool application called GTop ...
However, you need to give the configure.in script the `--without-gnome'
parameter when you want to use LibGTop without GNOME (this is because,
if you want to use it with GNOME, you need to compile it after the main
GNOME libraries and I wanted to avoid getting unnecessary bug reports
about this).
LIBGTOP AND GNOME - PART II:
---------------------------
LibGTop was tested with FreeBSD 3.0 but it should also work with
FreeBSD 2.2.7, NetBSD and OpenBSD.
Unfortunately, I don't have the power and disk space to install all
possible operating systems out there on my machine and test things myself,
so I depend on people telling me whether it works and sending me bug
reports and patches if not.
However, I consider FreeBSD, NetBSD and OpenBSD as supported systems for
LibGTop and whenever I get bug reports I will do my best to fix them as
quickly as possible.
PLATFORM SPECIFIC NOTES FOR LINUX:
==================================
[I am speaking of the Linux kernel here.]
Under Linux, LibGTop should work without problems and read everything
from /proc.
LibGTop 0.25 also had an experimental kernel interface to read this
information directly from the kernel with a system call - but I have
currently dropped support for this as I am too busy with GNOME
development to keep current with kernel hacking.
PLATFORM SPECIFIC NOTES FOR SOLARIS:
====================================
The development branch of LibGTop (the 1.1.x series) has a first version
of the Solaris port which works at least on Solaris 7.
If you are on a Solaris system and want to give it a try, just fetch the
latest 1.1.x tarball from ftp://ftp.home-of-linux.org/pub/libgtop/1.1/
and try it out.
PLATFORM SPECIFIC NOTES FOR BSD:
=================================
There are a few caveats:
* You need to manually make the `$(prefix)/bin/libgtop_server' SGID to
kmem after installation and mount the /proc file system of FreeBSD
(/proc/<pid>/mem is used within kvm_uread ()).
* To get the filenames of the process maps displayed in GTop, you need
to configure with the `--with-libgtop-inodedb' option (you need GDBM
for this to work).
You have then to create an inode database which is used to look up
filenames. This is done using the `mkinodedb' program which comes
along with libgtop.
See the file src/inodedb/README for details:
The `mkinodedb' program which is build in this directory takes two
command line arguments: the full pathname of the database to be
created and the name of a configuration file consisting of directory
and file names each on a line by itself - see `/etc/ld.so.conf' for
an example.
Putting a directory name in this file means all regular files found
in this directory are included in the database, but it will not
recursively descend into subdirectories (for instance, we want
everything in `/usr/lib' but not every single file in `/usr/lib/sgml').
You can also use filenames to include a single file.
Have fun,
Martin <martin@home-of-linux.org>

View File

@@ -1,50 +0,0 @@
RELEASE NOTES FOR LIBGTOP 1.1.2
===============================
This is a snapshot release for Solaris users of October GNOME. It contains
a first version of the Solaris port of LibGTop which works at least on
Solaris 7.
Please use LibGTop 1.0.x if you're not on a Solaris system
(look at the README file for details).
IMPORTANT CHANGES SINCE 1.0:
----------------------------
* All `glibtop_get_<feature>_* ()' and all `glibtop_init_<feature>_* ()'
functions now have an `int' return value and return 0 on success and -1
on failure.
* glibtop_cpu: Added `xcpu_flags'
* glibtop_proc_state: Changed `state' from char to unsigned and added
GLIBTOP_PROCESS_RUNNING, GLIBTOP_PROCESS_INTERRUPTIBLE,
GLIBTOP_PROCESS_UNINTERRUPTIBLE, GLIBTOP_PROCESS_ZOMBIE,
GLIBTOP_PROCESS_STOPPED, GLIBTOP_PROCESS_SWAPPING constants for it.
* `GLIBTOP_MOUNTENTRY_LEN' and `GLIBTOP_MAX_GROUPS' are now defined in
<glibtop/limits.h>
* Removed the `GLIBTOP_SYSDEPS_FEATURES' and `GLIBTOP_SYSDEPS_POINTER_SIZE'
constants from <glibtop/sysdeps.h> and let numbering start at zero for
`GLIBTOP_SYSDEPS_CPU'.
OTHER CHANGES SINCE 1.0:
-----------------------
* Use G_GNUC_UNUSED in <glibtop/error.h> to avoid compiler warnings.
* The `libgtop-config' script now accepts `--cflags', `--libs' and
`--extra-libs' parameter.
* The libraries are now called -lgtop-1.1 etc. so you can use 1.0.x and
1.1.x in parallel.
CHANGES SINCE 1.0 MAINLY INTERESTING FOR DEVELOPERS:
---------------------------------------------------
* We create a `glibtop-config.h' now which gets included from <glibtop.h>
when we're _IN_LIBGTOP. It contains things such as `u_int64_t' etc.
October 1999
Martin Baulig

View File

@@ -1,3 +1,13 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* backend-server.c: (_open_server):
* command.c: (glibtop_call_i):
* demarshal.pl:
* marshal.pl:
* read_data.c: (glibtop_read_data_i):
* server.c: (main), (handle_slave_connection):
replace all the xmalloc crap by glib memory management functions
2003-10-20 Bastien Nocera <hadess@hadess.net> 2003-10-20 Bastien Nocera <hadess@hadess.net>
* Makefile.am: removed traces of guile, intllibs and libgnomesupport * Makefile.am: removed traces of guile, intllibs and libgnomesupport

View File

@@ -51,7 +51,7 @@ _open_server (glibtop_server *server, glibtop_backend *backend,
{ {
backend_server_private *priv; backend_server_private *priv;
priv = glibtop_calloc_r (server, 1, sizeof (backend_server_private)); priv = g_malloc (sizeof (backend_server_private));
glibtop_backend_set_closure_data (backend, priv); glibtop_backend_set_closure_data (backend, priv);

View File

@@ -89,7 +89,7 @@ glibtop_call_i (glibtop_server *server, backend_server_private *priv,
glibtop_read_i (priv, recv_size, recv_ptr); glibtop_read_i (priv, recv_size, recv_ptr);
if (resp.data_size) { if (resp.data_size) {
void *ptr = glibtop_malloc_r (server, resp.data_size); void *ptr = g_malloc (server, resp.data_size);
glibtop_read_i (priv, resp.data_size, ptr); glibtop_read_i (priv, resp.data_size, ptr);

View File

@@ -247,7 +247,7 @@ sub output {
if ($line_fields[3] eq '') { if ($line_fields[3] eq '') {
$size_code .= "\t_LIBGTOP_RECV_buf = NULL;\n"; $size_code .= "\t_LIBGTOP_RECV_buf = NULL;\n";
} else { } else {
$size_code .= "\t_LIBGTOP_RECV_buf = glibtop_malloc_r (server, _LIBGTOP_RECV_len);\n"; $size_code .= "\t_LIBGTOP_RECV_buf = g_malloc (server, _LIBGTOP_RECV_len);\n";
} }
$size_code .= "\t_LIBGTOP_RECV_ptr = _LIBGTOP_RECV_buf;\n\n"; $size_code .= "\t_LIBGTOP_RECV_ptr = _LIBGTOP_RECV_buf;\n\n";
@@ -299,7 +299,7 @@ sub output {
$recv_buf_code .= "\n"; $recv_buf_code .= "\n";
$recv_buf_code .= "\t_LIBGTOP_TEMP_len += sizeof (off_t) + 1;\n"; $recv_buf_code .= "\t_LIBGTOP_TEMP_len += sizeof (off_t) + 1;\n";
$recv_buf_code .= "\t_LIBGTOP_TEMP_len += array.number * sizeof (off_t);\n"; $recv_buf_code .= "\t_LIBGTOP_TEMP_len += array.number * sizeof (off_t);\n";
$recv_buf_code .= "\t_LIBGTOP_ARRAY_base = glibtop_malloc_r (server, _LIBGTOP_TEMP_len);"; $recv_buf_code .= "\t_LIBGTOP_ARRAY_base = g_malloc (server, _LIBGTOP_TEMP_len);";
$recv_buf_code .= "\t_LIBGTOP_ARRAY_ptr = _LIBGTOP_ARRAY_base;\n"; $recv_buf_code .= "\t_LIBGTOP_ARRAY_ptr = _LIBGTOP_ARRAY_base;\n";
$recv_buf_code .= "\t_LIBGTOP_ARRAY_offset = array.number * sizeof (off_t);\n"; $recv_buf_code .= "\t_LIBGTOP_ARRAY_offset = array.number * sizeof (off_t);\n";
$recv_buf_code .= "\t_LIBGTOP_ARRAY_offset += sizeof (off_t);\n"; $recv_buf_code .= "\t_LIBGTOP_ARRAY_offset += sizeof (off_t);\n";

View File

@@ -181,7 +181,7 @@ sub output {
$send_buf_code = "\t/* send buffer */\n"; $send_buf_code = "\t/* send buffer */\n";
$send_buf_code .= "\t_LIBGTOP_SEND_buf = "; $send_buf_code .= "\t_LIBGTOP_SEND_buf = ";
if ($need_temp_storage) { if ($need_temp_storage) {
$send_buf_code .= "glibtop_malloc_r (server, _LIBGTOP_SEND_len+1)"; $send_buf_code .= "g_malloc (server, _LIBGTOP_SEND_len+1)";
} else { } else {
$send_buf_code .= '(void *) &'.$first_param_name; $send_buf_code .= '(void *) &'.$first_param_name;
} }
@@ -190,7 +190,7 @@ sub output {
$send_buf_code .= "\t/* data buffer */\n"; $send_buf_code .= "\t/* data buffer */\n";
$send_buf_code .= "\t_LIBGTOP_DATA_buf = "; $send_buf_code .= "\t_LIBGTOP_DATA_buf = ";
if ($need_temp_storage) { if ($need_temp_storage) {
$send_buf_code .= "glibtop_malloc_r (server, _LIBGTOP_DATA_len+1)"; $send_buf_code .= "g_malloc (server, _LIBGTOP_DATA_len+1)";
} else { } else {
$send_buf_code .= 'NULL'; $send_buf_code .= 'NULL';
} }
@@ -216,8 +216,8 @@ sub output {
$call_code .= sprintf ("\t\t\t%s%s);\n", $call_prefix_space, $retval_param); $call_code .= sprintf ("\t\t\t%s%s);\n", $call_prefix_space, $retval_param);
if ($need_temp_storage) { if ($need_temp_storage) {
$send_buf_free_code = "\tglibtop_free_r (server, _LIBGTOP_SEND_buf);\n"; $send_buf_free_code = "\tg_free (_LIBGTOP_SEND_buf);\n";
$send_buf_free_code .= "\tglibtop_free_r (server, _LIBGTOP_DATA_buf);\n"; $send_buf_free_code .= "\tg_free (_LIBGTOP_DATA_buf);\n";
} else { } else {
$send_buf_free_code = ""; $send_buf_free_code = "";
} }
@@ -231,14 +231,14 @@ sub output {
$local_var_code .= "\tchar *_LIBGTOP_ARRAY_ptr, **ptrlist;\n"; $local_var_code .= "\tchar *_LIBGTOP_ARRAY_ptr, **ptrlist;\n";
$local_var_code .= "\toff_t *_LIBGTOP_ARRAY_off_ptr;\n"; $local_var_code .= "\toff_t *_LIBGTOP_ARRAY_off_ptr;\n";
$local_var_code .= "\tint i;\n"; $local_var_code .= "\tint i;\n";
$call_code .= "\tptrlist = glibtop_calloc_r (server, array->number+1, sizeof (char *));\n"; $call_code .= "\tptrlist = g_malloc (server, array->number+1 * sizeof (char *));\n";
$call_code .= "\t_LIBGTOP_ARRAY_off_ptr = (off_t *) retval;\n"; $call_code .= "\t_LIBGTOP_ARRAY_off_ptr = (off_t *) retval;\n";
$call_code .= "\t_LIBGTOP_ARRAY_ptr = (char *) retval;\n"; $call_code .= "\t_LIBGTOP_ARRAY_ptr = (char *) retval;\n";
$call_code .= "\t_LIBGTOP_ARRAY_off_ptr++;\n\n"; $call_code .= "\t_LIBGTOP_ARRAY_off_ptr++;\n\n";
$call_code .= "\tfor (i = 0; i < array->number; i++)\n"; $call_code .= "\tfor (i = 0; i < array->number; i++)\n";
$call_code .= "\t\tptrlist [i] = glibtop_strdup_r (server, _LIBGTOP_ARRAY_ptr + *_LIBGTOP_ARRAY_off_ptr++);\n"; $call_code .= "\t\tptrlist [i] = g_strdup (_LIBGTOP_ARRAY_ptr + *_LIBGTOP_ARRAY_off_ptr++);\n";
$call_code .= "\tptrlist [array->number] = NULL;\n\n"; $call_code .= "\tptrlist [array->number] = NULL;\n\n";
$call_code .= "\tglibtop_free_r (server, retval);\n"; $call_code .= "\tg_free (retval);\n";
$call_code .= "\tretval = ptrlist;\n"; $call_code .= "\tretval = ptrlist;\n";
} }

View File

@@ -47,7 +47,7 @@ glibtop_read_data_i (backend_server_private *priv)
if (!size) return NULL; if (!size) return NULL;
ptr = glibtop_malloc_r (priv->server, size); ptr = g_malloc (priv->server, size);
ret = read (priv->input [0], ptr, size); ret = read (priv->input [0], ptr, size);

View File

@@ -88,8 +88,7 @@ main(int argc, char *argv[])
server = glibtop_global_server; server = glibtop_global_server;
if (!server->_priv) if (!server->_priv)
server->_priv = glibtop_calloc_r server->_priv = g_malloc (sizeof (glibtop_server_private));
(server, 1, sizeof (glibtop_server_private));
glibtop_init_p (server, 0, 0); glibtop_init_p (server, 0, 0);
@@ -156,7 +155,7 @@ handle_slave_connection (int input, int output)
cmnd->data_size); cmnd->data_size);
#endif #endif
data_ptr = glibtop_malloc_r (server, cmnd->data_size); data_ptr = g_malloc (server, cmnd->data_size);
do_read (input, data_ptr, cmnd->data_size); do_read (input, data_ptr, cmnd->data_size);
} }

View File

@@ -464,8 +464,8 @@ Size of a single entry in the returned list
(this equals @code{sizeof (unsigned)}). (this equals @code{sizeof (unsigned)}).
@end table @end table
The returned list is allocated using @code{glibtop_malloc} and must be freed The returned list is allocated using @code{g_malloc} and must be freed
using @code{glibtop_free} to avoid a memory leak. using @code{g_free} to avoid a memory leak.
@page @page
@node glibtop_proc_state, glibtop_proc_uid, glibtop_proclist, System Dependent @node glibtop_proc_state, glibtop_proc_uid, glibtop_proclist, System Dependent
@@ -1108,7 +1108,7 @@ Returns a string with all command line arguments of process @code{pid}
The command line arguments in the returned string are separated by zero bytes; The command line arguments in the returned string are separated by zero bytes;
the lenght of this string is returned in the @code{size} field. the lenght of this string is returned in the @code{size} field.
Remember to @code{glibtop_free} the returned string to avoid a memory leak. Remember to @code{g_free} the returned string to avoid a memory leak.
@page @page
@node glibtop_proc_map, glibtop_netload, glibtop_proc_args, System Dependent @node glibtop_proc_map, glibtop_netload, glibtop_proc_args, System Dependent
@@ -1144,7 +1144,7 @@ struct _glibtop_proc_map
@end example @end example
Returns a @code{glibtop_map_entry *} list (which needs to be freed with Returns a @code{glibtop_map_entry *} list (which needs to be freed with
@code{glibtop_free}) of memory maps of process @code{pid}. @code{g_free}) of memory maps of process @code{pid}.
@table @code @table @code
@item number @item number
@@ -1418,7 +1418,7 @@ struct _glibtop_mountlist
@end example @end example
Returns a @code{glibtop_mountentry *} list (which needs to be freed with Returns a @code{glibtop_mountentry *} list (which needs to be freed with
@code{glibtop_free}) of mounted filesystems. @code{g_free}) of mounted filesystems.
@table @code @table @code
@item number @item number

View File

@@ -232,7 +232,7 @@ main (int argc, char *argv [])
printf ("\n"); printf ("\n");
} }
glibtop_free (ptr); g_free (ptr);
pid = getpid (); pid = getpid ();
ppid = getppid (); ppid = getppid ();
@@ -346,7 +346,7 @@ main (int argc, char *argv [])
(unsigned long) data.proc_args.size, (unsigned long) data.proc_args.size,
args ? args : ""); args ? args : "");
glibtop_free (args); g_free (args);
printf ("\n"); printf ("\n");
@@ -456,7 +456,7 @@ main (int argc, char *argv [])
(unsigned long) data.proc_args.size, (unsigned long) data.proc_args.size,
args ? args : ""); args ? args : "");
glibtop_free (args); g_free (args);
printf ("\n"); printf ("\n");
@@ -567,7 +567,7 @@ main (int argc, char *argv [])
(unsigned long) data.proc_args.size, (unsigned long) data.proc_args.size,
args ? args : ""); args ? args : "");
glibtop_free (args); g_free (args);
glibtop_close (); glibtop_close ();

View File

@@ -73,7 +73,7 @@ main (int argc, char *argv [])
for (c = 0; c < PROFILE_COUNT; c++) { for (c = 0; c < PROFILE_COUNT; c++) {
mount_entries = glibtop_get_mountlist (&mount_list, 1); mount_entries = glibtop_get_mountlist (&mount_list, 1);
glibtop_free (mount_entries); g_free (mount_entries);
} }
printf ("sbrk (0) = %p\n\n", sbrk (0)); printf ("sbrk (0) = %p\n\n", sbrk (0));
@@ -103,7 +103,7 @@ main (int argc, char *argv [])
fsusage.ffree); fsusage.ffree);
} }
glibtop_free (mount_entries); g_free (mount_entries);
printf ("\nsbrk (0) = %p\n\n", sbrk (0)); printf ("\nsbrk (0) = %p\n\n", sbrk (0));

View File

@@ -82,8 +82,8 @@ main (int argc, char *argv [])
addr.s_addr = netload.address; addr.s_addr = netload.address;
subnet.s_addr = netload.subnet; subnet.s_addr = netload.subnet;
address_string = glibtop_strdup (inet_ntoa (addr)); address_string = g_strdup (inet_ntoa (addr));
subnet_string = glibtop_strdup (inet_ntoa (subnet)); subnet_string = g_strdup (inet_ntoa (subnet));
printf ("Network Load (0x%08lx):\n\n" printf ("Network Load (0x%08lx):\n\n"
"\tInterface Flags:\t0x%08lx\n" "\tInterface Flags:\t0x%08lx\n"
@@ -116,8 +116,8 @@ main (int argc, char *argv [])
(unsigned long) netload.errors_out, (unsigned long) netload.errors_out,
(unsigned long) netload.errors_total); (unsigned long) netload.errors_total);
glibtop_free (address_string); g_free (address_string);
glibtop_free (subnet_string); g_free (subnet_string);
glibtop_close (); glibtop_close ();

View File

@@ -153,10 +153,10 @@ main (int argc, char *argv [])
} }
if (filename && (filename != maps [i].filename)) if (filename && (filename != maps [i].filename))
glibtop_free (filename); g_free (filename);
} }
glibtop_free (maps); g_free (maps);
glibtop_close (); glibtop_close ();

View File

@@ -151,7 +151,7 @@ output (pid_t pid)
(unsigned long) data.proc_args.size, (unsigned long) data.proc_args.size,
args ? args : ""); args ? args : "");
glibtop_free (args); g_free (args);
printf ("\n"); printf ("\n");
@@ -291,7 +291,7 @@ main (int argc, char *argv [])
output (pid); output (pid);
} }
glibtop_free (ptr); g_free (ptr);
exit (0); exit (0);
} }

View File

@@ -187,7 +187,7 @@ main (int argc, char *argv [])
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) { for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
ptr = glibtop_get_proclist (&data.proclist, 0, 0); ptr = glibtop_get_proclist (&data.proclist, 0, 0);
glibtop_free (ptr); g_free (ptr);
} }
getrusage (RUSAGE_SELF, &rusage_end); getrusage (RUSAGE_SELF, &rusage_end);

View File

@@ -4,7 +4,7 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
sem_limits.h uptime.h command.h mem.h proclist.h \ sem_limits.h uptime.h command.h mem.h proclist.h \
proctime.h shm_limits.h version.h cpu.h msg_limits.h \ proctime.h shm_limits.h version.h cpu.h msg_limits.h \
procmem.h procuid.h swap.h write.h error.h open.h \ procmem.h procuid.h swap.h write.h error.h open.h \
procsegment.h read.h sysdeps.h xmalloc.h global.h \ procsegment.h read.h sysdeps.h global.h \
procsignal.h read_data.h union.h types.h gnuserv.h \ procsignal.h read_data.h union.h types.h gnuserv.h \
parameter.h mountlist.h fsusage.h procmap.h signal.h \ parameter.h mountlist.h fsusage.h procmap.h signal.h \
inodedb.h sysinfo.h ppp.h procargs.h netload.h inodedb.h sysinfo.h ppp.h procargs.h netload.h

View File

@@ -1,46 +0,0 @@
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __GLIBTOP_XMALLOC_H__
#define __GLIBTOP_XMALLOC_H__
#include <glibtop.h>
#include <glibtop/error.h>
BEGIN_LIBGTOP_DECLS
#define glibtop_malloc(p1) glibtop_malloc_r(glibtop_global_server, p1)
#define glibtop_calloc(p1, p2) glibtop_calloc_r(glibtop_global_server, p1, p2)
#define glibtop_realloc(p1, p2) glibtop_realloc_r(glibtop_global_server, p1, p2)
#define glibtop_strdup(p1) glibtop_strdup_r(glibtop_global_server, p1)
#define glibtop_free(p1) glibtop_free_r(glibtop_global_server, p1)
void *glibtop_malloc_r (glibtop *server, size_t size);
void *glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size);
void *glibtop_realloc_r (glibtop *server, void *ptr, size_t size);
char *glibtop_strdup_r (glibtop *server, const char *string);
void glibtop_free_r (glibtop *server, const void *ptr);
END_LIBGTOP_DECLS
#endif

View File

@@ -66,7 +66,7 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
recv_size); recv_size);
if (response.data_size) { if (response.data_size) {
void *ptr = glibtop_malloc_r (server, response.data_size); void *ptr = g_malloc (server, response.data_size);
glibtop_read_l (server, response.data_size, ptr); glibtop_read_l (server, response.data_size, ptr);

View File

@@ -45,14 +45,14 @@ _init_server (glibtop *server, const unsigned features)
const char *temp = getenv ("LIBGTOP_SERVER") ? const char *temp = getenv ("LIBGTOP_SERVER") ?
getenv ("LIBGTOP_SERVER") : LIBGTOP_SERVER; getenv ("LIBGTOP_SERVER") : LIBGTOP_SERVER;
server->server_command = glibtop_strdup_r (server, temp); server->server_command = g_strdup (temp);
} }
if (server->server_rsh == NULL) { if (server->server_rsh == NULL) {
const char *temp = getenv ("LIBGTOP_RSH") ? const char *temp = getenv ("LIBGTOP_RSH") ?
getenv ("LIBGTOP_RSH") : "/usr/bin/ssh"; getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
server->server_rsh = glibtop_strdup_r (server, temp); server->server_rsh = g_strdup (temp);
} }
/* Try to get server method, but don't override if already /* Try to get server method, but don't override if already
@@ -82,7 +82,7 @@ _init_server (glibtop *server, const unsigned features)
/* Everything up to the next colon is the method. */ /* Everything up to the next colon is the method. */
command = glibtop_strdup_r (server, server->server_command+1); command = g_strdup (server->server_command+1);
temp = strstr (command, ":"); temp = strstr (command, ":");
if (temp) *temp = 0; if (temp) *temp = 0;
@@ -103,19 +103,16 @@ _init_server (glibtop *server, const unsigned features)
if (temp == NULL) { if (temp == NULL) {
/* If no value was set, we use 'localhost'. */ /* If no value was set, we use 'localhost'. */
if (server->server_host == NULL) if (server->server_host == NULL)
server->server_host = glibtop_strdup_r server->server_host = g_strdup ("localhost");
(server, "localhost");
} else { } else {
char *temp2 = strstr (temp+1, ":"); char *temp2 = strstr (temp+1, ":");
if (temp2) *temp2 = 0; if (temp2) *temp2 = 0;
/* Override default. */ /* Override default. */
if (server->server_host) if (server->server_host)
glibtop_free_r (server, g_free ((char *) server->server_host);
(char *) server->server_host);
server->server_host = glibtop_strdup_r server->server_host = g_strdup (temp+1);
(server, temp+1);
temp = temp2; temp = temp2;
} }
@@ -151,7 +148,7 @@ _init_server (glibtop *server, const unsigned features)
} }
glibtop_free_r (server, command); g_free (command);
} }
glibtop * glibtop *

View File

@@ -45,7 +45,7 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
if (!databases) if (!databases)
databases = GLIBTOP_INODEDB_ALL; databases = GLIBTOP_INODEDB_ALL;
inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb)); inodedb = g_malloc (sizeof (glibtop_inodedb));
if (stat (SYSTEM_INODEDB, &statb)) if (stat (SYSTEM_INODEDB, &statb))
databases &= ~GLIBTOP_INODEDB_SYSTEM; databases &= ~GLIBTOP_INODEDB_SYSTEM;
@@ -113,5 +113,5 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
if (inodedb->user_dbf) if (inodedb->user_dbf)
gdbm_close (inodedb->user_dbf); gdbm_close (inodedb->user_dbf);
glibtop_free_r (server, inodedb); g_free (inodedb);
} }

View File

@@ -54,7 +54,7 @@ glibtop_read_data_l (glibtop *server)
if (!size) return NULL; if (!size) return NULL;
ptr = glibtop_malloc_r (server, size); ptr = g_malloc (server, size);
if (server->socket) { if (server->socket) {
ret = recv (server->socket, ptr, size, 0); ret = recv (server->socket, ptr, size, 0);

View File

@@ -1,98 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop/xmalloc.h>
#ifdef LIBGTOP_USE_GLIB_MALLOC
#include <glib.h>
#endif
/* Wrappers to malloc, calloc, realloc ... */
void *
glibtop_malloc_r (glibtop_server *server, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
return g_malloc0 (size);
#else
void *buf = malloc (size);
if (!buf)
glibtop_error_io_r (server, "malloc %d bytes", size);
return buf;
#endif
}
void *
glibtop_calloc_r (glibtop_server *server, size_t nmemb, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
return g_malloc0 (size * nmemb);
#else
void *buf = calloc (nmemb, size);
if (!buf)
glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
nmemb, size);
return buf;
#endif
}
void *
glibtop_realloc_r (glibtop_server *server, void *ptr, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
return g_realloc (ptr, size);
#else
void *buf = realloc (ptr, size);
if (!buf)
glibtop_error_io_r (server, "realloc %d bytes", size);
return buf;
#endif
}
char *
glibtop_strdup_r (glibtop_server *server, const char *string)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
return g_strdup (string);
#else
return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
#endif
}
void
glibtop_free_r (glibtop_server *server, void *ptr)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
g_free (ptr);
#else
if (ptr) free ((void *) ptr);
#endif
}

View File

@@ -1,3 +1,9 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* main.c: (handle_parent_connection):
* slave.c: (handle_slave_connection):
replace all the xmalloc crap by glib memory management functions
2003-10-20 Bastien Nocera <hadess@hadess.net> 2003-10-20 Bastien Nocera <hadess@hadess.net>
* Makefile.am: removed traces of guile, intllibs and libgnomesupport * Makefile.am: removed traces of guile, intllibs and libgnomesupport

View File

@@ -140,7 +140,7 @@ handle_parent_connection (int s)
param_ptr [1]); param_ptr [1]);
do_output (s, resp, _offset_data (proclist), do_output (s, resp, _offset_data (proclist),
resp->u.data.proclist.total, ptr); resp->u.data.proclist.total, ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
case GLIBTOP_CMND_PROC_MAP: case GLIBTOP_CMND_PROC_MAP:
memcpy (&pid, parameter, sizeof (pid_t)); memcpy (&pid, parameter, sizeof (pid_t));
@@ -149,7 +149,7 @@ handle_parent_connection (int s)
pid); pid);
do_output (s, resp, _offset_data (proc_map), do_output (s, resp, _offset_data (proc_map),
resp->u.data.proc_map.total, ptr); resp->u.data.proc_map.total, ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
case GLIBTOP_CMND_PROC_ARGS: case GLIBTOP_CMND_PROC_ARGS:
memcpy (&pid, parameter, sizeof (pid_t)); memcpy (&pid, parameter, sizeof (pid_t));
@@ -158,7 +158,7 @@ handle_parent_connection (int s)
pid, 0); pid, 0);
do_output (s, resp, _offset_data (proc_args), do_output (s, resp, _offset_data (proc_args),
ptr ? resp->u.data.proc_args.size+1 : 0, ptr); ptr ? resp->u.data.proc_args.size+1 : 0, ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
case GLIBTOP_CMND_PROC_STATE: case GLIBTOP_CMND_PROC_STATE:
memcpy (&pid, parameter, sizeof (pid_t)); memcpy (&pid, parameter, sizeof (pid_t));
@@ -208,7 +208,7 @@ handle_parent_connection (int s)
(server, &resp->u.data.mountlist, all_fs); (server, &resp->u.data.mountlist, all_fs);
do_output (s, resp, _offset_data (mountlist), do_output (s, resp, _offset_data (mountlist),
resp->u.data.mountlist.total, mount_list); resp->u.data.mountlist.total, mount_list);
glibtop_free_r (server, mount_list); g_free (mount_list);
break; break;
case GLIBTOP_CMND_FSUSAGE: case GLIBTOP_CMND_FSUSAGE:
glibtop_get_fsusage_l glibtop_get_fsusage_l

View File

@@ -78,7 +78,7 @@ handle_slave_connection (int input, int output)
param_ptr [0], param_ptr [1]); param_ptr [0], param_ptr [1]);
do_output (output, resp, _offset_data (proclist), do_output (output, resp, _offset_data (proclist),
resp->u.data.proclist.total, ptr); resp->u.data.proclist.total, ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
#endif #endif
#if GLIBTOP_SUID_PROC_ARGS #if GLIBTOP_SUID_PROC_ARGS
@@ -92,7 +92,7 @@ handle_slave_connection (int input, int output)
do_output (output, resp, _offset_data (proc_args), do_output (output, resp, _offset_data (proc_args),
ptr ? resp->u.data.proc_args.size+1 : 0, ptr ? resp->u.data.proc_args.size+1 : 0,
ptr); ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
#endif #endif
#if GLIBTOP_SUID_PROC_MAP #if GLIBTOP_SUID_PROC_MAP
@@ -103,7 +103,7 @@ handle_slave_connection (int input, int output)
pid); pid);
do_output (output, resp, _offset_data (proc_map), do_output (output, resp, _offset_data (proc_map),
resp->u.data.proc_map.total, ptr); resp->u.data.proc_map.total, ptr);
glibtop_free_r (server, ptr); g_free (ptr);
break; break;
#endif #endif
default: default:

View File

@@ -64,7 +64,7 @@ glibtop_inodedb_lookup_s (glibtop *server, glibtop_inodedb *inodedb,
u_int64_t device, u_int64_t inode) u_int64_t device, u_int64_t inode)
It will either return a pointer to the filename - which you have to It will either return a pointer to the filename - which you have to
`glibtop_free ()' once done with it - or NULL on error. `g_free ()' once done with it - or NULL on error.
You can use the `file_by_inode' program in this directory to test the You can use the `file_by_inode' program in this directory to test the
interface - just call it with two command line arguments: the device number interface - just call it with two command line arguments: the device number

View File

@@ -1,3 +1,9 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* procargs.c: (glibtop_get_proc_args_s):
* proclist.c: (glibtop_get_proclist_s):
replace all the xmalloc crap by glib memory management functions
2003-10-20 Bastien Nocera <hadess@hadess.net> 2003-10-20 Bastien Nocera <hadess@hadess.net>
* .cvsignore: added * .cvsignore: added

View File

@@ -74,7 +74,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
} }
size = max_len != 0 ? max_len : 4096; size = max_len != 0 ? max_len : 4096;
args_buffer = glibtop_malloc_r (server, size); args_buffer = g_malloc (server, size);
if (args_buffer == NULL) if (args_buffer == NULL)
{ {
glibtop_error_io_r (server, "Cannot malloc procsinfo"); glibtop_error_io_r (server, "Cannot malloc procsinfo");
@@ -88,7 +88,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
{ {
glibtop_error_io_r (server, "Cannot malloc getargs"); glibtop_error_io_r (server, "Cannot malloc getargs");
glibtop_free_r(server, args_buffer); g_free(args_buffer);
return NULL; return NULL;
} }
@@ -97,7 +97,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
if (args_buffer[0] == 0) if (args_buffer[0] == 0)
{ {
glibtop_free_r(server, args_buffer); g_free(args_buffer);
return NULL; return NULL;
} }
@@ -112,17 +112,17 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
len += strlen(args_buffer + len) + 1; len += strlen(args_buffer + len) + 1;
} }
args = glibtop_malloc_r (server, len); args = g_malloc (server, len);
if (args == NULL) if (args == NULL)
{ {
glibtop_error_io_r (server, "Cannot malloc procsinfo"); glibtop_error_io_r (server, "Cannot malloc procsinfo");
glibtop_free_r(server, args_buffer); g_free(args_buffer);
return NULL; return NULL;
} }
memcpy(args, args_buffer, len); memcpy(args, args_buffer, len);
glibtop_free_r(server, args_buffer); g_free(args_buffer);
buf->size = len - 1; buf->size = len - 1;

View File

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

View File

@@ -1,3 +1,12 @@
2003-10-20 Bastien Nocera <hadess@hadess.net>
* Makefile.am:
* inodedb.c: (glibtop_inodedb_open_s), (glibtop_inodedb_close_s):
* mountlist.c: (glibtop_get_mountlist_s):
* xmalloc.c:
* xmalloc_suid.c: replace all the xmalloc crap by glib memory
management functions
2000-01-20 Martin Baulig <martin@home-of-linux.org> 2000-01-20 Martin Baulig <martin@home-of-linux.org>
* fsusage.c (adjust_blocks): Use `u_int64_t' arguments and * fsusage.c (adjust_blocks): Use `u_int64_t' arguments and

View File

@@ -14,14 +14,14 @@ CFLAGS = @CFLAGS@ $(inodedb_DEFS)
lib_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la lib_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la
libgtop_common_2_0_la_SOURCES = xmalloc.c error.c gnuslib.c \ libgtop_common_2_0_la_SOURCES = error.c gnuslib.c \
fsusage.c fsusage.h mountlist.c mountlist.h \ fsusage.c fsusage.h mountlist.c mountlist.h \
$(inodedb_SRCLIST) $(inodedb_SRCLIST)
libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_common_2_0_la_LIBADD = $(LIBGTOP_EXTRA_LIBS) libgtop_common_2_0_la_LIBADD = $(LIBGTOP_EXTRA_LIBS)
libgtop_suid_common_2_0_la_SOURCES = xmalloc.c error.c sysdeps_suid.c libgtop_suid_common_2_0_la_SOURCES = error.c sysdeps_suid.c
libgtop_suid_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_suid_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)

View File

@@ -45,7 +45,7 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
if (!databases) if (!databases)
databases = GLIBTOP_INODEDB_ALL; databases = GLIBTOP_INODEDB_ALL;
inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb)); inodedb = g_malloc (sizeof (glibtop_inodedb));
if (stat (SYSTEM_INODEDB, &statb)) if (stat (SYSTEM_INODEDB, &statb))
databases &= ~GLIBTOP_INODEDB_SYSTEM; databases &= ~GLIBTOP_INODEDB_SYSTEM;
@@ -113,5 +113,5 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
if (inodedb->user_dbf) if (inodedb->user_dbf)
gdbm_close (inodedb->user_dbf); gdbm_close (inodedb->user_dbf);
glibtop_free_r (server, inodedb); g_free (server, inodedb);
} }

View File

@@ -44,10 +44,10 @@ static struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs);
#undef xrealloc #undef xrealloc
#undef xstrdup #undef xstrdup
#define xmalloc(p1) glibtop_malloc_r (NULL, p1) #define xmalloc(p1) g_malloc (NULL, p1)
#define xrealloc(p1,p2) glibtop_realloc_r (NULL, p1, p2) #define xrealloc(p1,p2) g_realloc (p1, p2)
#define xstrdup(p1) glibtop_strdup_r (NULL, p1) #define xstrdup(p1) g_strdup (NULL, p1)
#define xfree(p1) glibtop_free_r (NULL, p1) #define xfree(p1) g_free (NULL, p1)
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
@@ -613,7 +613,7 @@ glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
buf->total = buf->number * buf->size; buf->total = buf->number * buf->size;
mount_list = glibtop_malloc_r (server, buf->total); mount_list = g_malloc (server, buf->total);
/* Write data into mount_list. */ /* Write data into mount_list. */

View File

@@ -1,72 +0,0 @@
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop/xmalloc.h>
/* Wrappers to malloc, calloc, realloc ... */
void *
glibtop_malloc_r (glibtop *server, size_t size)
{
void *buf = malloc (size);
if (!buf)
glibtop_error_io_r (server, "malloc %d bytes", size);
return buf;
}
void *
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
{
void *buf = calloc (nmemb, size);
if (!buf)
glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
nmemb, size);
return buf;
}
void *
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
{
void *buf = realloc (ptr, size);
if (!buf)
glibtop_error_io_r (server, "realloc %d bytes", size);
return buf;
}
char *
glibtop_strdup_r (glibtop *server, const char *string)
{
return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
}
void
glibtop_free_r (glibtop *server, const void *ptr)
{
if (ptr) free ((void *) ptr);
}

View File

@@ -1,74 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop/xmalloc.h>
/* Wrappers to malloc, calloc, realloc ... */
void *
glibtop_malloc_r (glibtop_server *server, size_t size)
{
void *buf = malloc (size);
if (!buf)
glibtop_error_io_r (server, "malloc %d bytes", size);
return buf;
}
void *
glibtop_calloc_r (glibtop_server *server, size_t nmemb, size_t size)
{
void *buf = calloc (nmemb, size);
if (!buf)
glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
nmemb, size);
return buf;
}
void *
glibtop_realloc_r (glibtop_server *server, void *ptr, size_t size)
{
void *buf = realloc (ptr, size);
if (!buf)
glibtop_error_io_r (server, "realloc %d bytes", size);
return buf;
}
char *
glibtop_strdup_r (glibtop_server *server, const char *string)
{
return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
}
void
glibtop_free_r (glibtop_server *server, const void *ptr)
{
if (ptr) free ((void *) ptr);
}

View File

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

View File

@@ -94,7 +94,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
size += strlen (*ptr)+1; size += strlen (*ptr)+1;
size += 2; size += 2;
retval = glibtop_malloc_r (server, size); retval = g_malloc (server, size);
memset (retval, 0, size); memset (retval, 0, size);
for (ptr = args; *ptr; ptr++) { for (ptr = args; *ptr; ptr++) {

View File

@@ -83,7 +83,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
/* Allocate count objects in the pids_chain array /* Allocate count objects in the pids_chain array
* Same as malloc is pids is NULL, which it is. */ * Same as malloc is pids is NULL, which it is. */
pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned)); pids = g_realloc (pids, count * sizeof (unsigned));
/* Copy the pids over to this chain */ /* Copy the pids over to this chain */
for (i=j=0; i < count; i++) { for (i=j=0; i < count; i++) {
if ((real_which & GLIBTOP_EXCLUDE_IDLE) && if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&

View File

@@ -132,7 +132,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
buf->total = buf->number * buf->size; buf->total = buf->number * buf->size;
maps = glibtop_malloc_r (server, buf->total); maps = g_malloc (server, buf->total);
memset (maps, 0, buf->total); memset (maps, 0, buf->total);

View File

@@ -269,14 +269,14 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
/* List of swap devices and sizes. */ /* List of swap devices and sizes. */
sw_size = nswdev * sizeof (*sw); sw_size = nswdev * sizeof (*sw);
sw = glibtop_malloc_r (server, sw_size); sw = g_malloc (server, sw_size);
if (kvm_read (server->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) { if (kvm_read (server->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) {
glibtop_warn_io_r (server, "kvm_read (*swdevt)"); glibtop_warn_io_r (server, "kvm_read (*swdevt)");
return; return;
} }
perdev = glibtop_malloc (nswdev * sizeof (*perdev)); perdev = g_malloc (nswdev * sizeof (*perdev));
/* Count up swap space. */ /* Count up swap space. */
@@ -353,8 +353,8 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
*/ */
inuse = avail - nfree; inuse = avail - nfree;
glibtop_free_r (server, sw); g_free (sw);
glibtop_free_r (server, perdev); g_free (perdev);
buf->flags = _glibtop_sysdeps_swap; buf->flags = _glibtop_sysdeps_swap;
@@ -401,11 +401,11 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
return; return;
} }
swaplist = glibtop_calloc_r (server, nswap, sizeof (struct swapent)); swaplist = g_malloc (server, nswap * sizeof (struct swapent));
if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) { if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) {
glibtop_warn_io_r (server, "swapctl (SWAP_STATS)"); glibtop_warn_io_r (server, "swapctl (SWAP_STATS)");
glibtop_free_r (server, swaplist); g_free (swaplist);
return; return;
} }
@@ -414,7 +414,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
inuse += swaplist[i].se_inuse; inuse += swaplist[i].se_inuse;
} }
glibtop_free_r (server, swaplist); g_free (swaplist);
buf->flags = _glibtop_sysdeps_swap; buf->flags = _glibtop_sysdeps_swap;

View File

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

View File

@@ -78,7 +78,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
buf->total = buf->number * sizeof (unsigned); buf->total = buf->number * sizeof (unsigned);
pids_chain = glibtop_malloc_r (server, buf->total); pids_chain = g_malloc (server, buf->total);
memcpy (pids_chain, tbl.proclist.pids, buf->total); memcpy (pids_chain, tbl.proclist.pids, buf->total);

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> 2001-10-17 Abel Cheung <maddog@linux.org.hk>
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. * 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; *in = *out = 0;
isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2, isdn_stats = g_malloc (ISDN_MAX_CHANNELS * 2 * sizeof (unsigned long));
sizeof (unsigned long));
fd = open ("/dev/isdninfo", O_RDONLY); fd = open ("/dev/isdninfo", O_RDONLY);
if (fd < 0) { if (fd < 0) {
glibtop_free_r (server, isdn_stats); g_free (isdn_stats);
return FALSE; return FALSE;
} }
if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) { if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
glibtop_free_r (server, isdn_stats); g_free (isdn_stats);
close (fd); close (fd);
return FALSE; return FALSE;
@@ -75,7 +74,7 @@ get_ISDN_stats (glibtop *server, int *in, int *out)
*in += *ptr++; *out += *ptr++; *in += *ptr++; *out += *ptr++;
} }
glibtop_free_r (server, isdn_stats); g_free (isdn_stats);
close (fd); close (fd);
return TRUE; 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 (cmdline < 0) return NULL;
if (max_len) { if (max_len) {
retval = glibtop_malloc_r (server, max_len+1); retval = g_malloc (server, max_len+1);
len = read (cmdline, retval, max_len); len = read (cmdline, retval, max_len);
close (cmdline); close (cmdline);
if (len < 0) { if (len < 0) {
glibtop_free_r (server, retval); g_free (retval);
return NULL; return NULL;
} }
@@ -79,14 +79,14 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
len = read (cmdline, buffer, BUFSIZ-1); len = read (cmdline, buffer, BUFSIZ-1);
if (len < 0) { if (len < 0) {
close (cmdline); close (cmdline);
glibtop_free_r (server, retval); g_free (retval);
return NULL; return NULL;
} }
if (len == 0) if (len == 0)
break; break;
retval = glibtop_realloc_r (server, retval, total+len+1); retval = g_realloc (retval, total+len+1);
memcpy (retval+total, buffer, len); memcpy (retval+total, buffer, len);
*(retval+total+len) = 0; *(retval+total+len) = 0;
total += len; 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. */ * full, we copy it to the pids_chain. */
if (count >= BLOCK_COUNT) { if (count >= BLOCK_COUNT) {
/* The following call to glibtop_realloc will be /* The following call to g_realloc will be
* equivalent to glibtop_malloc () if `pids_chain' is * equivalent to g_malloc () if `pids_chain' is
* NULL. We just calculate the new size and copy `pids' * NULL. We just calculate the new size and copy `pids'
* to the beginning of the newly allocated block. */ * to the beginning of the newly allocated block. */
new_size = pids_size + BLOCK_SIZE; new_size = pids_size + BLOCK_SIZE;
pids_chain = glibtop_realloc_r pids_chain = g_realloc (pids_chain, new_size);
(server, pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, BLOCK_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; if (!count) return NULL;
/* The following call to glibtop_realloc will be equivalent to /* The following call to g_realloc will be equivalent to
* glibtop_malloc if pids_chain is NULL. We just calculate the * g_malloc if pids_chain is NULL. We just calculate the
* new size and copy pids to the beginning of the newly allocated * new size and copy pids to the beginning of the newly allocated
* block. */ * block. */
new_size = pids_size + count * sizeof (unsigned); 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)); 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); 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)); memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry));

View File

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

View File

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

View File

@@ -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> 2001-10-17 Abel Cheung <maddog@linux.org.hk>
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.

View File

@@ -61,7 +61,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
break; break;
if(max_len) if(max_len)
{ {
ret = glibtop_malloc_r(server, max_len + 1); ret = g_malloc(server, max_len + 1);
if(max_len < len) if(max_len < len)
len = max_len; len = max_len;
memcpy(ret, pinfo.pr_psargs, len); memcpy(ret, pinfo.pr_psargs, len);
@@ -69,7 +69,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
} }
else else
{ {
ret = glibtop_malloc_r(server, len + 1); ret = g_malloc(server, len + 1);
memcpy(ret, pinfo.pr_psargs, len); memcpy(ret, pinfo.pr_psargs, len);
ret[len] = 0; ret[len] = 0;

View File

@@ -97,7 +97,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
if(s_stat(buffer, &statb) < 0) if(s_stat(buffer, &statb) < 0)
return NULL; return NULL;
} }
if(!(pids_chain = glibtop_malloc(sizeof(unsigned)))) if(!(pids_chain = g_malloc(sizeof(unsigned))))
return NULL; return NULL;
*pids_chain = pid; *pids_chain = pid;
return pids_chain; return pids_chain;
@@ -189,15 +189,14 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
* full, we copy it to the pids_chain. */ * full, we copy it to the pids_chain. */
if (count >= BLOCK_COUNT) { if (count >= BLOCK_COUNT) {
/* The following call to glibtop_realloc will be /* The following call to g_realloc will be
* equivalent to glibtop_malloc () if `pids_chain' is * equivalent to g_malloc () if `pids_chain' is
* NULL. We just calculate the new size and copy `pids' * NULL. We just calculate the new size and copy `pids'
* to the beginning of the newly allocated block. */ * to the beginning of the newly allocated block. */
new_size = pids_size + BLOCK_SIZE; new_size = pids_size + BLOCK_SIZE;
pids_chain = glibtop_realloc_r pids_chain = g_realloc (pids_chain, new_size);
(server, pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, BLOCK_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; if (!count) return NULL;
/* The following call to glibtop_realloc will be equivalent to /* The following call to g_realloc will be equivalent to
* glibtop_malloc if pids_chain is NULL. We just calculate the * g_malloc if pids_chain is NULL. We just calculate the
* new size and copy pids to the beginning of the newly allocated * new size and copy pids to the beginning of the newly allocated
* block. */ * block. */
new_size = pids_size + count * sizeof (unsigned); 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)); memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));

View File

@@ -121,7 +121,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
return NULL; return NULL;
} }
#endif #endif
if(!(entry = glibtop_malloc_r(server, if(!(entry = g_malloc(server,
nmaps * sizeof(glibtop_map_entry)))) nmaps * sizeof(glibtop_map_entry))))
return NULL; return NULL;
buf->number = nmaps; buf->number = nmaps;

View File

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

View File

@@ -149,7 +149,7 @@ glibtop_open_p (glibtop *server, const char *program_name,
server->machine.ptable_size = (unsigned long) server->machine.nproc * server->machine.ptable_size = (unsigned long) server->machine.nproc *
(unsigned long) sizeof (struct proc); (unsigned long) sizeof (struct proc);
server->machine.proc_table = glibtop_malloc_r server->machine.proc_table = g_malloc
(server, server->machine.ptable_size); (server, server->machine.ptable_size);
/* This are for the memory statistics. */ /* This are for the memory statistics. */
@@ -170,7 +170,7 @@ glibtop_open_p (glibtop *server, const char *program_name,
sizeof (struct page); sizeof (struct page);
server->machine.physpage = (struct page *) server->machine.physpage = (struct page *)
glibtop_malloc_r (server, server->machine.bytesize); g_malloc (server, server->machine.bytesize);
/* get the page size with "getpagesize" and /* get the page size with "getpagesize" and
* calculate pageshift from it */ * calculate pageshift from it */

View File

@@ -72,7 +72,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
proc_size = nproc * sizeof (unsigned); proc_size = nproc * sizeof (unsigned);
proc_list = glibtop_malloc_r (server, proc_size); proc_list = g_malloc (server, proc_size);
/* Write process list. */ /* Write process list. */