- replace all the xmalloc crap by glib memory management functions
This commit is contained in:
20
ChangeLog
20
ChangeLog
@@ -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>
|
||||
|
||||
* lib/Makefile.am:
|
||||
@@ -977,7 +993,7 @@
|
||||
* include/glibtop/command.h (glibtop_call): Third argument is
|
||||
now `const void *'.
|
||||
|
||||
* include/glibtop/xmalloc.h (glibtop_free): Now taking a
|
||||
* include/glibtop/xmalloc.h (g_free): Now taking a
|
||||
`const void *'.
|
||||
|
||||
1998-08-25 Martin Baulig <martin@home-of-linux.org>
|
||||
@@ -1563,7 +1579,7 @@
|
||||
|
||||
* 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.
|
||||
|
||||
|
146
RELNOTES-0.25
146
RELNOTES-0.25
@@ -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>
|
163
RELNOTES-1.0
163
RELNOTES-1.0
@@ -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>
|
172
RELNOTES-1.0.x
172
RELNOTES-1.0.x
@@ -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>
|
@@ -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
|
@@ -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>
|
||||
|
||||
* Makefile.am: removed traces of guile, intllibs and libgnomesupport
|
||||
|
@@ -51,7 +51,7 @@ _open_server (glibtop_server *server, glibtop_backend *backend,
|
||||
{
|
||||
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);
|
||||
|
||||
|
@@ -89,7 +89,7 @@ glibtop_call_i (glibtop_server *server, backend_server_private *priv,
|
||||
glibtop_read_i (priv, recv_size, recv_ptr);
|
||||
|
||||
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);
|
||||
|
||||
|
@@ -247,7 +247,7 @@ sub output {
|
||||
if ($line_fields[3] eq '') {
|
||||
$size_code .= "\t_LIBGTOP_RECV_buf = NULL;\n";
|
||||
} 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";
|
||||
|
||||
@@ -299,7 +299,7 @@ sub output {
|
||||
$recv_buf_code .= "\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_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_offset = array.number * sizeof (off_t);\n";
|
||||
$recv_buf_code .= "\t_LIBGTOP_ARRAY_offset += sizeof (off_t);\n";
|
||||
|
@@ -181,7 +181,7 @@ sub output {
|
||||
$send_buf_code = "\t/* send buffer */\n";
|
||||
$send_buf_code .= "\t_LIBGTOP_SEND_buf = ";
|
||||
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 {
|
||||
$send_buf_code .= '(void *) &'.$first_param_name;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ sub output {
|
||||
$send_buf_code .= "\t/* data buffer */\n";
|
||||
$send_buf_code .= "\t_LIBGTOP_DATA_buf = ";
|
||||
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 {
|
||||
$send_buf_code .= 'NULL';
|
||||
}
|
||||
@@ -216,8 +216,8 @@ sub output {
|
||||
$call_code .= sprintf ("\t\t\t%s%s);\n", $call_prefix_space, $retval_param);
|
||||
|
||||
if ($need_temp_storage) {
|
||||
$send_buf_free_code = "\tglibtop_free_r (server, _LIBGTOP_SEND_buf);\n";
|
||||
$send_buf_free_code .= "\tglibtop_free_r (server, _LIBGTOP_DATA_buf);\n";
|
||||
$send_buf_free_code = "\tg_free (_LIBGTOP_SEND_buf);\n";
|
||||
$send_buf_free_code .= "\tg_free (_LIBGTOP_DATA_buf);\n";
|
||||
} else {
|
||||
$send_buf_free_code = "";
|
||||
}
|
||||
@@ -231,14 +231,14 @@ sub output {
|
||||
$local_var_code .= "\tchar *_LIBGTOP_ARRAY_ptr, **ptrlist;\n";
|
||||
$local_var_code .= "\toff_t *_LIBGTOP_ARRAY_off_ptr;\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_ptr = (char *) retval;\n";
|
||||
$call_code .= "\t_LIBGTOP_ARRAY_off_ptr++;\n\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 .= "\tglibtop_free_r (server, retval);\n";
|
||||
$call_code .= "\tg_free (retval);\n";
|
||||
$call_code .= "\tretval = ptrlist;\n";
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,7 @@ glibtop_read_data_i (backend_server_private *priv)
|
||||
|
||||
if (!size) return NULL;
|
||||
|
||||
ptr = glibtop_malloc_r (priv->server, size);
|
||||
ptr = g_malloc (priv->server, size);
|
||||
|
||||
ret = read (priv->input [0], ptr, size);
|
||||
|
||||
|
@@ -88,8 +88,7 @@ main(int argc, char *argv[])
|
||||
server = glibtop_global_server;
|
||||
|
||||
if (!server->_priv)
|
||||
server->_priv = glibtop_calloc_r
|
||||
(server, 1, sizeof (glibtop_server_private));
|
||||
server->_priv = g_malloc (sizeof (glibtop_server_private));
|
||||
|
||||
glibtop_init_p (server, 0, 0);
|
||||
|
||||
@@ -156,7 +155,7 @@ handle_slave_connection (int input, int output)
|
||||
cmnd->data_size);
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@@ -464,8 +464,8 @@ Size of a single entry in the returned list
|
||||
(this equals @code{sizeof (unsigned)}).
|
||||
@end table
|
||||
|
||||
The returned list is allocated using @code{glibtop_malloc} and must be freed
|
||||
using @code{glibtop_free} to avoid a memory leak.
|
||||
The returned list is allocated using @code{g_malloc} and must be freed
|
||||
using @code{g_free} to avoid a memory leak.
|
||||
|
||||
@page
|
||||
@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 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
|
||||
@node glibtop_proc_map, glibtop_netload, glibtop_proc_args, System Dependent
|
||||
@@ -1144,7 +1144,7 @@ struct _glibtop_proc_map
|
||||
@end example
|
||||
|
||||
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
|
||||
@item number
|
||||
@@ -1418,7 +1418,7 @@ struct _glibtop_mountlist
|
||||
@end example
|
||||
|
||||
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
|
||||
@item number
|
||||
|
@@ -232,7 +232,7 @@ main (int argc, char *argv [])
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
glibtop_free (ptr);
|
||||
g_free (ptr);
|
||||
|
||||
pid = getpid ();
|
||||
ppid = getppid ();
|
||||
@@ -346,7 +346,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_args.size,
|
||||
args ? args : "");
|
||||
|
||||
glibtop_free (args);
|
||||
g_free (args);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
@@ -456,7 +456,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_args.size,
|
||||
args ? args : "");
|
||||
|
||||
glibtop_free (args);
|
||||
g_free (args);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
@@ -567,7 +567,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_args.size,
|
||||
args ? args : "");
|
||||
|
||||
glibtop_free (args);
|
||||
g_free (args);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
|
@@ -73,7 +73,7 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++) {
|
||||
mount_entries = glibtop_get_mountlist (&mount_list, 1);
|
||||
|
||||
glibtop_free (mount_entries);
|
||||
g_free (mount_entries);
|
||||
}
|
||||
|
||||
printf ("sbrk (0) = %p\n\n", sbrk (0));
|
||||
@@ -103,7 +103,7 @@ main (int argc, char *argv [])
|
||||
fsusage.ffree);
|
||||
}
|
||||
|
||||
glibtop_free (mount_entries);
|
||||
g_free (mount_entries);
|
||||
|
||||
printf ("\nsbrk (0) = %p\n\n", sbrk (0));
|
||||
|
||||
|
@@ -82,8 +82,8 @@ main (int argc, char *argv [])
|
||||
addr.s_addr = netload.address;
|
||||
subnet.s_addr = netload.subnet;
|
||||
|
||||
address_string = glibtop_strdup (inet_ntoa (addr));
|
||||
subnet_string = glibtop_strdup (inet_ntoa (subnet));
|
||||
address_string = g_strdup (inet_ntoa (addr));
|
||||
subnet_string = g_strdup (inet_ntoa (subnet));
|
||||
|
||||
printf ("Network Load (0x%08lx):\n\n"
|
||||
"\tInterface Flags:\t0x%08lx\n"
|
||||
@@ -116,8 +116,8 @@ main (int argc, char *argv [])
|
||||
(unsigned long) netload.errors_out,
|
||||
(unsigned long) netload.errors_total);
|
||||
|
||||
glibtop_free (address_string);
|
||||
glibtop_free (subnet_string);
|
||||
g_free (address_string);
|
||||
g_free (subnet_string);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
|
@@ -153,10 +153,10 @@ main (int argc, char *argv [])
|
||||
}
|
||||
|
||||
if (filename && (filename != maps [i].filename))
|
||||
glibtop_free (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
glibtop_free (maps);
|
||||
g_free (maps);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
|
@@ -151,7 +151,7 @@ output (pid_t pid)
|
||||
(unsigned long) data.proc_args.size,
|
||||
args ? args : "");
|
||||
|
||||
glibtop_free (args);
|
||||
g_free (args);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
@@ -291,7 +291,7 @@ main (int argc, char *argv [])
|
||||
output (pid);
|
||||
}
|
||||
|
||||
glibtop_free (ptr);
|
||||
g_free (ptr);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
@@ -187,7 +187,7 @@ main (int argc, char *argv [])
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
|
||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||
glibtop_free (ptr);
|
||||
g_free (ptr);
|
||||
}
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
@@ -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 \
|
||||
proctime.h shm_limits.h version.h cpu.h msg_limits.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 \
|
||||
parameter.h mountlist.h fsusage.h procmap.h signal.h \
|
||||
inodedb.h sysinfo.h ppp.h procargs.h netload.h
|
||||
|
@@ -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
|
@@ -66,7 +66,7 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
||||
recv_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);
|
||||
|
||||
|
17
lib/init.c
17
lib/init.c
@@ -45,14 +45,14 @@ _init_server (glibtop *server, const unsigned features)
|
||||
const char *temp = getenv ("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) {
|
||||
const char *temp = getenv ("LIBGTOP_RSH") ?
|
||||
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
|
||||
@@ -82,7 +82,7 @@ _init_server (glibtop *server, const unsigned features)
|
||||
|
||||
/* 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, ":");
|
||||
if (temp) *temp = 0;
|
||||
|
||||
@@ -103,19 +103,16 @@ _init_server (glibtop *server, const unsigned features)
|
||||
if (temp == NULL) {
|
||||
/* If no value was set, we use 'localhost'. */
|
||||
if (server->server_host == NULL)
|
||||
server->server_host = glibtop_strdup_r
|
||||
(server, "localhost");
|
||||
server->server_host = g_strdup ("localhost");
|
||||
} else {
|
||||
char *temp2 = strstr (temp+1, ":");
|
||||
if (temp2) *temp2 = 0;
|
||||
|
||||
/* Override default. */
|
||||
if (server->server_host)
|
||||
glibtop_free_r (server,
|
||||
(char *) server->server_host);
|
||||
g_free ((char *) server->server_host);
|
||||
|
||||
server->server_host = glibtop_strdup_r
|
||||
(server, temp+1);
|
||||
server->server_host = g_strdup (temp+1);
|
||||
|
||||
temp = temp2;
|
||||
}
|
||||
@@ -151,7 +148,7 @@ _init_server (glibtop *server, const unsigned features)
|
||||
|
||||
}
|
||||
|
||||
glibtop_free_r (server, command);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
glibtop *
|
||||
|
@@ -45,7 +45,7 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
|
||||
if (!databases)
|
||||
databases = GLIBTOP_INODEDB_ALL;
|
||||
|
||||
inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
|
||||
inodedb = g_malloc (sizeof (glibtop_inodedb));
|
||||
|
||||
if (stat (SYSTEM_INODEDB, &statb))
|
||||
databases &= ~GLIBTOP_INODEDB_SYSTEM;
|
||||
@@ -113,5 +113,5 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
|
||||
if (inodedb->user_dbf)
|
||||
gdbm_close (inodedb->user_dbf);
|
||||
|
||||
glibtop_free_r (server, inodedb);
|
||||
g_free (inodedb);
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ glibtop_read_data_l (glibtop *server)
|
||||
|
||||
if (!size) return NULL;
|
||||
|
||||
ptr = glibtop_malloc_r (server, size);
|
||||
ptr = g_malloc (server, size);
|
||||
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, ptr, size, 0);
|
||||
|
@@ -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
|
||||
}
|
@@ -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>
|
||||
|
||||
* Makefile.am: removed traces of guile, intllibs and libgnomesupport
|
||||
|
@@ -140,7 +140,7 @@ handle_parent_connection (int s)
|
||||
param_ptr [1]);
|
||||
do_output (s, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_MAP:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
@@ -149,7 +149,7 @@ handle_parent_connection (int s)
|
||||
pid);
|
||||
do_output (s, resp, _offset_data (proc_map),
|
||||
resp->u.data.proc_map.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_ARGS:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
@@ -158,7 +158,7 @@ handle_parent_connection (int s)
|
||||
pid, 0);
|
||||
do_output (s, resp, _offset_data (proc_args),
|
||||
ptr ? resp->u.data.proc_args.size+1 : 0, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
@@ -208,7 +208,7 @@ handle_parent_connection (int s)
|
||||
(server, &resp->u.data.mountlist, all_fs);
|
||||
do_output (s, resp, _offset_data (mountlist),
|
||||
resp->u.data.mountlist.total, mount_list);
|
||||
glibtop_free_r (server, mount_list);
|
||||
g_free (mount_list);
|
||||
break;
|
||||
case GLIBTOP_CMND_FSUSAGE:
|
||||
glibtop_get_fsusage_l
|
||||
|
@@ -78,7 +78,7 @@ handle_slave_connection (int input, int output)
|
||||
param_ptr [0], param_ptr [1]);
|
||||
do_output (output, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_ARGS
|
||||
@@ -92,7 +92,7 @@ handle_slave_connection (int input, int output)
|
||||
do_output (output, resp, _offset_data (proc_args),
|
||||
ptr ? resp->u.data.proc_args.size+1 : 0,
|
||||
ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_MAP
|
||||
@@ -103,7 +103,7 @@ handle_slave_connection (int input, int output)
|
||||
pid);
|
||||
do_output (output, resp, _offset_data (proc_map),
|
||||
resp->u.data.proc_map.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
g_free (ptr);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@@ -64,7 +64,7 @@ glibtop_inodedb_lookup_s (glibtop *server, glibtop_inodedb *inodedb,
|
||||
u_int64_t device, u_int64_t inode)
|
||||
|
||||
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
|
||||
interface - just call it with two command line arguments: the device number
|
||||
|
@@ -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>
|
||||
|
||||
* .cvsignore: added
|
||||
|
@@ -74,7 +74,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
}
|
||||
|
||||
size = max_len != 0 ? max_len : 4096;
|
||||
args_buffer = glibtop_malloc_r (server, size);
|
||||
args_buffer = g_malloc (server, size);
|
||||
if (args_buffer == NULL)
|
||||
{
|
||||
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_free_r(server, args_buffer);
|
||||
g_free(args_buffer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
|
||||
if (args_buffer[0] == 0)
|
||||
{
|
||||
glibtop_free_r(server, args_buffer);
|
||||
g_free(args_buffer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -112,17 +112,17 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
len += strlen(args_buffer + len) + 1;
|
||||
}
|
||||
|
||||
args = glibtop_malloc_r (server, len);
|
||||
args = g_malloc (server, len);
|
||||
if (args == NULL)
|
||||
{
|
||||
glibtop_error_io_r (server, "Cannot malloc procsinfo");
|
||||
|
||||
glibtop_free_r(server, args_buffer);
|
||||
g_free(args_buffer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
memcpy(args, args_buffer, len);
|
||||
glibtop_free_r(server, args_buffer);
|
||||
g_free(args_buffer);
|
||||
|
||||
buf->size = len - 1;
|
||||
|
||||
|
@@ -188,15 +188,15 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
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);
|
||||
|
||||
pids_size = new_size;
|
||||
@@ -221,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));
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
* fsusage.c (adjust_blocks): Use `u_int64_t' arguments and
|
||||
|
@@ -14,14 +14,14 @@ CFLAGS = @CFLAGS@ $(inodedb_DEFS)
|
||||
|
||||
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 \
|
||||
$(inodedb_SRCLIST)
|
||||
|
||||
libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
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)
|
||||
|
||||
|
@@ -45,7 +45,7 @@ glibtop_inodedb_open_s (glibtop *server, unsigned databases,
|
||||
if (!databases)
|
||||
databases = GLIBTOP_INODEDB_ALL;
|
||||
|
||||
inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
|
||||
inodedb = g_malloc (sizeof (glibtop_inodedb));
|
||||
|
||||
if (stat (SYSTEM_INODEDB, &statb))
|
||||
databases &= ~GLIBTOP_INODEDB_SYSTEM;
|
||||
@@ -113,5 +113,5 @@ glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
|
||||
if (inodedb->user_dbf)
|
||||
gdbm_close (inodedb->user_dbf);
|
||||
|
||||
glibtop_free_r (server, inodedb);
|
||||
g_free (server, inodedb);
|
||||
}
|
||||
|
@@ -44,10 +44,10 @@ static struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs);
|
||||
#undef xrealloc
|
||||
#undef xstrdup
|
||||
|
||||
#define xmalloc(p1) glibtop_malloc_r (NULL, p1)
|
||||
#define xrealloc(p1,p2) glibtop_realloc_r (NULL, p1, p2)
|
||||
#define xstrdup(p1) glibtop_strdup_r (NULL, p1)
|
||||
#define xfree(p1) glibtop_free_r (NULL, p1)
|
||||
#define xmalloc(p1) g_malloc (NULL, p1)
|
||||
#define xrealloc(p1,p2) g_realloc (p1, p2)
|
||||
#define xstrdup(p1) g_strdup (NULL, p1)
|
||||
#define xfree(p1) g_free (NULL, p1)
|
||||
|
||||
#ifdef HAVE_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;
|
||||
|
||||
mount_list = glibtop_malloc_r (server, buf->total);
|
||||
mount_list = g_malloc (server, buf->total);
|
||||
|
||||
/* Write data into mount_list. */
|
||||
|
||||
|
@@ -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);
|
||||
}
|
@@ -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);
|
||||
}
|
@@ -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>
|
||||
|
||||
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.
|
||||
|
@@ -94,7 +94,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
size += strlen (*ptr)+1;
|
||||
|
||||
size += 2;
|
||||
retval = glibtop_malloc_r (server, size);
|
||||
retval = g_malloc (server, size);
|
||||
memset (retval, 0, size);
|
||||
|
||||
for (ptr = args; *ptr; ptr++) {
|
||||
|
@@ -83,7 +83,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
/* Allocate count objects in the pids_chain array
|
||||
* 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 */
|
||||
for (i=j=0; i < count; i++) {
|
||||
if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
|
||||
|
@@ -132,7 +132,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
maps = glibtop_malloc_r (server, buf->total);
|
||||
maps = g_malloc (server, buf->total);
|
||||
|
||||
memset (maps, 0, buf->total);
|
||||
|
||||
|
@@ -269,14 +269,14 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
/* List of swap devices and sizes. */
|
||||
|
||||
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) {
|
||||
glibtop_warn_io_r (server, "kvm_read (*swdevt)");
|
||||
return;
|
||||
}
|
||||
|
||||
perdev = glibtop_malloc (nswdev * sizeof (*perdev));
|
||||
perdev = g_malloc (nswdev * sizeof (*perdev));
|
||||
|
||||
/* Count up swap space. */
|
||||
|
||||
@@ -353,8 +353,8 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
*/
|
||||
inuse = avail - nfree;
|
||||
|
||||
glibtop_free_r (server, sw);
|
||||
glibtop_free_r (server, perdev);
|
||||
g_free (sw);
|
||||
g_free (perdev);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
@@ -401,11 +401,11 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
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) {
|
||||
glibtop_warn_io_r (server, "swapctl (SWAP_STATS)");
|
||||
glibtop_free_r (server, swaplist);
|
||||
g_free (swaplist);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
inuse += swaplist[i].se_inuse;
|
||||
}
|
||||
|
||||
glibtop_free_r (server, swaplist);
|
||||
g_free (swaplist);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.
|
||||
|
@@ -78,7 +78,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
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);
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.
|
||||
|
@@ -108,15 +108,15 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
if (count >= BLOCK_COUNT) {
|
||||
|
||||
/* The following call to glibtop_realloc ()
|
||||
* will be equivalent to glibtop_malloc ()
|
||||
/* 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
|
||||
pids_chain = g_realloc
|
||||
(server, pids_chain, new_size);
|
||||
|
||||
memcpy (pids_chain + pids_offset,
|
||||
@@ -143,14 +143,14 @@ glibtop_get_proclist_p (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 (server, pids_chain, new_size);
|
||||
|
||||
memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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>
|
||||
|
||||
* Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.
|
||||
|
@@ -149,7 +149,7 @@ glibtop_open_p (glibtop *server, const char *program_name,
|
||||
server->machine.ptable_size = (unsigned long) server->machine.nproc *
|
||||
(unsigned long) sizeof (struct proc);
|
||||
|
||||
server->machine.proc_table = glibtop_malloc_r
|
||||
server->machine.proc_table = g_malloc
|
||||
(server, server->machine.ptable_size);
|
||||
|
||||
/* This are for the memory statistics. */
|
||||
@@ -170,7 +170,7 @@ glibtop_open_p (glibtop *server, const char *program_name,
|
||||
sizeof (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
|
||||
* calculate pageshift from it */
|
||||
|
@@ -72,7 +72,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
proc_size = nproc * sizeof (unsigned);
|
||||
|
||||
proc_list = glibtop_malloc_r (server, proc_size);
|
||||
proc_list = g_malloc (server, proc_size);
|
||||
|
||||
/* Write process list. */
|
||||
|
||||
|
Reference in New Issue
Block a user