diff --git a/ChangeLog b/ChangeLog index 8c20c3f9..797a8250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2003-10-20 Bastien Nocera + + * 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 * 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 @@ -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. diff --git a/RELNOTES-0.25 b/RELNOTES-0.25 deleted file mode 100644 index d00152e4..00000000 --- a/RELNOTES-0.25 +++ /dev/null @@ -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//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//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 diff --git a/RELNOTES-1.0 b/RELNOTES-1.0 deleted file mode 100644 index 321683f8..00000000 --- a/RELNOTES-1.0 +++ /dev/null @@ -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//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//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 diff --git a/RELNOTES-1.0.x b/RELNOTES-1.0.x deleted file mode 100644 index d1d7ad64..00000000 --- a/RELNOTES-1.0.x +++ /dev/null @@ -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//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//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 diff --git a/RELNOTES-1.1.x b/RELNOTES-1.1.x deleted file mode 100644 index 4fb1aeb7..00000000 --- a/RELNOTES-1.1.x +++ /dev/null @@ -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__* ()' and all `glibtop_init__* ()' - 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 - - -* Removed the `GLIBTOP_SYSDEPS_FEATURES' and `GLIBTOP_SYSDEPS_POINTER_SIZE' - constants from and let numbering start at zero for - `GLIBTOP_SYSDEPS_CPU'. - -OTHER CHANGES SINCE 1.0: ------------------------ - -* Use G_GNUC_UNUSED in 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 - when we're _IN_LIBGTOP. It contains things such as `u_int64_t' etc. - -October 1999 -Martin Baulig diff --git a/backends/server/ChangeLog b/backends/server/ChangeLog index 8c9f2133..a7b8aa24 100644 --- a/backends/server/ChangeLog +++ b/backends/server/ChangeLog @@ -1,3 +1,13 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: removed traces of guile, intllibs and libgnomesupport diff --git a/backends/server/backend-server.c b/backends/server/backend-server.c index 743e62e4..9add91df 100644 --- a/backends/server/backend-server.c +++ b/backends/server/backend-server.c @@ -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); diff --git a/backends/server/command.c b/backends/server/command.c index 1821b938..2cdacd2f 100644 --- a/backends/server/command.c +++ b/backends/server/command.c @@ -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); diff --git a/backends/server/demarshal.pl b/backends/server/demarshal.pl index 9726906b..cf9e4e0b 100644 --- a/backends/server/demarshal.pl +++ b/backends/server/demarshal.pl @@ -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"; diff --git a/backends/server/marshal.pl b/backends/server/marshal.pl index d00dc5e9..ef6ff4ae 100644 --- a/backends/server/marshal.pl +++ b/backends/server/marshal.pl @@ -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"; } diff --git a/backends/server/read_data.c b/backends/server/read_data.c index 1922e1af..120711c8 100644 --- a/backends/server/read_data.c +++ b/backends/server/read_data.c @@ -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); diff --git a/backends/server/server.c b/backends/server/server.c index 5500380b..65420de8 100644 --- a/backends/server/server.c +++ b/backends/server/server.c @@ -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); } diff --git a/doc/reference.texi b/doc/reference.texi index 4a94cb69..5799a469 100644 --- a/doc/reference.texi +++ b/doc/reference.texi @@ -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 diff --git a/examples/first.c b/examples/first.c index 26249817..d57513fd 100644 --- a/examples/first.c +++ b/examples/first.c @@ -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 (); diff --git a/examples/mountlist.c b/examples/mountlist.c index f4c6c0c6..bbfccf2b 100644 --- a/examples/mountlist.c +++ b/examples/mountlist.c @@ -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)); diff --git a/examples/netload.c b/examples/netload.c index f77130d2..5e7524f6 100644 --- a/examples/netload.c +++ b/examples/netload.c @@ -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 (); diff --git a/examples/procmap.c b/examples/procmap.c index 163e3671..f3e0ac0f 100644 --- a/examples/procmap.c +++ b/examples/procmap.c @@ -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 (); diff --git a/examples/second.c b/examples/second.c index b65bf86f..15f18d80 100644 --- a/examples/second.c +++ b/examples/second.c @@ -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); } diff --git a/examples/timings.c b/examples/timings.c index 5874fa18..4f62c41c 100644 --- a/examples/timings.c +++ b/examples/timings.c @@ -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); diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 6dc4ede6..43735148 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -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 diff --git a/include/glibtop/xmalloc.h b/include/glibtop/xmalloc.h deleted file mode 100644 index 9f5eac06..00000000 --- a/include/glibtop/xmalloc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 -#include - -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 diff --git a/lib/command.c b/lib/command.c index be59c38d..593d9df8 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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); diff --git a/lib/init.c b/lib/init.c index 38299612..07778b4b 100644 --- a/lib/init.c +++ b/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 * diff --git a/lib/inodedb.c b/lib/inodedb.c index d78d3905..1920ad20 100644 --- a/lib/inodedb.c +++ b/lib/inodedb.c @@ -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); } diff --git a/lib/read_data.c b/lib/read_data.c index 8c1bc416..f04072d0 100644 --- a/lib/read_data.c +++ b/lib/read_data.c @@ -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); diff --git a/lib/xmalloc.c b/lib/xmalloc.c deleted file mode 100644 index c8342c79..00000000 --- a/lib/xmalloc.c +++ /dev/null @@ -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 , 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 - -#ifdef LIBGTOP_USE_GLIB_MALLOC -#include -#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 -} diff --git a/src/daemon/ChangeLog b/src/daemon/ChangeLog index 36c5efd4..28d499ab 100644 --- a/src/daemon/ChangeLog +++ b/src/daemon/ChangeLog @@ -1,3 +1,9 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: removed traces of guile, intllibs and libgnomesupport diff --git a/src/daemon/main.c b/src/daemon/main.c index 36154cfe..82272ff1 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -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 diff --git a/src/daemon/slave.c b/src/daemon/slave.c index f8d5a492..bd093173 100644 --- a/src/daemon/slave.c +++ b/src/daemon/slave.c @@ -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: diff --git a/src/inodedb/README.inodedb b/src/inodedb/README.inodedb index 82d9ecc5..bbd15db5 100644 --- a/src/inodedb/README.inodedb +++ b/src/inodedb/README.inodedb @@ -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 diff --git a/sysdeps/aix/ChangeLog b/sysdeps/aix/ChangeLog index c3f9d2f2..03f85ca0 100644 --- a/sysdeps/aix/ChangeLog +++ b/sysdeps/aix/ChangeLog @@ -1,3 +1,9 @@ +2003-10-20 Bastien Nocera + + * 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 * .cvsignore: added diff --git a/sysdeps/aix/procargs.c b/sysdeps/aix/procargs.c index 97bf0b34..af55e1cb 100644 --- a/sysdeps/aix/procargs.c +++ b/sysdeps/aix/procargs.c @@ -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; diff --git a/sysdeps/aix/proclist.c b/sysdeps/aix/proclist.c index b92c5669..3cf11d96 100644 --- a/sysdeps/aix/proclist.c +++ b/sysdeps/aix/proclist.c @@ -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)); diff --git a/sysdeps/common/ChangeLog b/sysdeps/common/ChangeLog index 79d68071..aa795abd 100644 --- a/sysdeps/common/ChangeLog +++ b/sysdeps/common/ChangeLog @@ -1,3 +1,12 @@ +2003-10-20 Bastien Nocera + + * 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 * fsusage.c (adjust_blocks): Use `u_int64_t' arguments and diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index a472f0e9..b6b56a93 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -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) diff --git a/sysdeps/common/inodedb.c b/sysdeps/common/inodedb.c index d78d3905..df5777d6 100644 --- a/sysdeps/common/inodedb.c +++ b/sysdeps/common/inodedb.c @@ -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); } diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index d8db10db..ce8f3dea 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -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 @@ -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. */ diff --git a/sysdeps/common/xmalloc.c b/sysdeps/common/xmalloc.c deleted file mode 100644 index d8d0080f..00000000 --- a/sysdeps/common/xmalloc.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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 - -/* 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); -} diff --git a/sysdeps/common/xmalloc_suid.c b/sysdeps/common/xmalloc_suid.c deleted file mode 100644 index 516f9143..00000000 --- a/sysdeps/common/xmalloc_suid.c +++ /dev/null @@ -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 , 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 - -/* 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); -} diff --git a/sysdeps/freebsd/ChangeLog b/sysdeps/freebsd/ChangeLog index 72a89fa7..16ca55c3 100644 --- a/sysdeps/freebsd/ChangeLog +++ b/sysdeps/freebsd/ChangeLog @@ -1,3 +1,11 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/freebsd/procargs.c b/sysdeps/freebsd/procargs.c index 83b6a78b..8e0ff2e7 100644 --- a/sysdeps/freebsd/procargs.c +++ b/sysdeps/freebsd/procargs.c @@ -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++) { diff --git a/sysdeps/freebsd/proclist.c b/sysdeps/freebsd/proclist.c index 20353ec5..789e6937 100644 --- a/sysdeps/freebsd/proclist.c +++ b/sysdeps/freebsd/proclist.c @@ -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) && diff --git a/sysdeps/freebsd/procmap.c b/sysdeps/freebsd/procmap.c index f29445b5..cf32421d 100644 --- a/sysdeps/freebsd/procmap.c +++ b/sysdeps/freebsd/procmap.c @@ -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); diff --git a/sysdeps/freebsd/swap.c b/sysdeps/freebsd/swap.c index d9669fa6..b28d74b1 100644 --- a/sysdeps/freebsd/swap.c +++ b/sysdeps/freebsd/swap.c @@ -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; diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog index e833f0aa..f9b5a978 100644 --- a/sysdeps/kernel/ChangeLog +++ b/sysdeps/kernel/ChangeLog @@ -1,3 +1,8 @@ +2003-10-20 Bastien Nocera + + * proclist.c: (glibtop_get_proclist_s): replace all the xmalloc crap + by glib memory management functions + 2001-10-17 Abel Cheung * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c index 9b527aaf..2311e6f8 100644 --- a/sysdeps/kernel/proclist.c +++ b/sysdeps/kernel/proclist.c @@ -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); diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 006529a2..eed7464d 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,11 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/linux/ppp.c b/sysdeps/linux/ppp.c index ca476f8e..99808e88 100644 --- a/sysdeps/linux/ppp.c +++ b/sysdeps/linux/ppp.c @@ -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; diff --git a/sysdeps/linux/procargs.c b/sysdeps/linux/procargs.c index 5436bbdb..3e4b63b2 100644 --- a/sysdeps/linux/procargs.c +++ b/sysdeps/linux/procargs.c @@ -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; diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index cb6a664d..11900bc2 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -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)); diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c index 9052c84a..87129d20 100644 --- a/sysdeps/linux/procmap.c +++ b/sysdeps/linux/procmap.c @@ -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)); diff --git a/sysdeps/osf1/ChangeLog b/sysdeps/osf1/ChangeLog index 76846805..d87225f7 100644 --- a/sysdeps/osf1/ChangeLog +++ b/sysdeps/osf1/ChangeLog @@ -1,3 +1,8 @@ +2003-10-20 Bastien Nocera + + * proclist.c: (glibtop_get_proclist_p): + replace all the xmalloc crap by glib memory management functions + 2001-10-17 Abel Cheung * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/osf1/proclist.c b/sysdeps/osf1/proclist.c index 607aeeae..35953c53 100644 --- a/sysdeps/osf1/proclist.c +++ b/sysdeps/osf1/proclist.c @@ -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)); diff --git a/sysdeps/solaris/ChangeLog b/sysdeps/solaris/ChangeLog index 16c829a7..e67739ce 100644 --- a/sysdeps/solaris/ChangeLog +++ b/sysdeps/solaris/ChangeLog @@ -1,3 +1,10 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/solaris/procargs.c b/sysdeps/solaris/procargs.c index ac2721d3..85582862 100644 --- a/sysdeps/solaris/procargs.c +++ b/sysdeps/solaris/procargs.c @@ -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; diff --git a/sysdeps/solaris/proclist.c b/sysdeps/solaris/proclist.c index 956ab0a0..44965bbf 100644 --- a/sysdeps/solaris/proclist.c +++ b/sysdeps/solaris/proclist.c @@ -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)); diff --git a/sysdeps/solaris/procmap.c b/sysdeps/solaris/procmap.c index daa2ba00..6ac000f6 100644 --- a/sysdeps/solaris/procmap.c +++ b/sysdeps/solaris/procmap.c @@ -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; diff --git a/sysdeps/sun4/ChangeLog b/sysdeps/sun4/ChangeLog index f05eac85..3ab3c2c7 100644 --- a/sysdeps/sun4/ChangeLog +++ b/sysdeps/sun4/ChangeLog @@ -1,3 +1,9 @@ +2003-10-20 Bastien Nocera + + * 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 * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop. diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 30fd3e1e..e68884fa 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -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 */ diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c index 4b6fc42e..4719a6bd 100644 --- a/sysdeps/sun4/proclist.c +++ b/sysdeps/sun4/proclist.c @@ -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. */