memory leak fixed

This commit is contained in:
albert 2003-02-11 08:19:12 +00:00
parent f5702f2c75
commit 27ed270851
4 changed files with 38 additions and 34 deletions

1
NEWS
View File

@ -1,5 +1,6 @@
procps-3.1.5 --> procps-3.1.6
top: memory leak fixed
ps: new --ppid option selects by PPID
watch: new --no-title option
handle SPARC Linux badness

View File

@ -34,8 +34,12 @@
#define STRTOUKL strtoul
#endif
// since gcc-2.5
#define NORETURN __attribute__((__noreturn__))
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
#if !defined(restrict) && __STDC_VERSION__ < 199901
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92 // maybe 92 or 95 ?
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
#define restrict __restrict__
#else
#warning No restrict keyword?
@ -43,35 +47,6 @@
#endif
#endif
// marks old junk, to warn non-procps library users
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
#define OBSOLETE __attribute__((deprecated))
#else
#define OBSOLETE
#endif
// Tells gcc that function is library-internal;
// so no need to do dynamic linking at run-time.
// This might work with slightly older compilers too.
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 1 ) || __GNUC__ > 3
#define HIDDEN __attribute__((visibility("hidden")))
#else
#define HIDDEN
#endif
// Like HIDDEN, but for an alias that gets created.
// In gcc-3.2 there is an alias+hidden conflict.
// Many will have patched this bug, but oh well.
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden")))
#else
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x)))
#endif
// since gcc-2.5
#define NORETURN __attribute__((__noreturn__))
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
// won't alias anything, and aligned enough for anything
#define MALLOC __attribute__ ((__malloc__))
@ -89,4 +64,32 @@
#define expected(x,y) (x)
#endif
// marks old junk, to warn non-procps library users
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
#define OBSOLETE __attribute__((deprecated))
#else
#define OBSOLETE
#endif
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 1 ) || __GNUC__ > 3
// Tells gcc that function is library-internal;
// so no need to do dynamic linking at run-time.
// This might work with slightly older compilers too.
#define HIDDEN __attribute__((visibility("hidden")))
// Tell g++ that a function won't throw exceptions.
#define NOTHROW __attribute__((__nothrow__))
#else
#define HIDDEN
#define NOTHROW
#endif
// Like HIDDEN, but for an alias that gets created.
// In gcc-3.2 there is an alias+hidden conflict.
// Many will have patched this bug, but oh well.
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden")))
#else
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x)))
#endif
#endif

View File

@ -212,7 +212,6 @@ extern void freeproc(proc_t* p);
#define PROC_FILLWCHAN 0x0080 /* look up WCHAN name */
#define PROC_FILLARG 0x0100 /* alloc and fill in `cmdline' */
#define PROC_FILLBUG 0x0fff /* No idea what we need */
#define PROC_FILLANY 0x0000 /* either stat or status will do */
/* Obsolete, consider only processes with one of the passed: */

7
top.c
View File

@ -1021,7 +1021,7 @@ static proc_t **procs_refresh (proc_t **table, int flags)
prochlp(NULL); // prep for a new frame
if (Monpidsidx)
PT = openproc(PROC_FILLBUG | PROC_PID, Monpids);
PT = openproc(flags, Monpids);
else
PT = openproc(flags);
@ -2096,6 +2096,7 @@ static void reframewins (void)
if (!(Frames_libflags & L_stat)) Frames_libflags |= L_status;
}
if (!Frames_libflags) Frames_libflags = L_DEFAULT;
if (selection_type=='p') Frames_libflags |= PROC_PID;
}
@ -2801,7 +2802,7 @@ static proc_t **summary_show (void)
// whoa first time, gotta' prime the pump...
if (!p_table) {
p_table = procs_refresh(NULL, L_DEFAULT);
p_table = procs_refresh(NULL, Frames_libflags);
putp(Cap_clr_scr);
sleep(1);
} else
@ -3141,7 +3142,7 @@ static void frame_make (void)
proc_t **ppt;
int i, scrlins;
/* note: except for PROC_PID, all libproc flags are managed by
/* note: all libproc flags are managed by
reframewins(), who also builds each window's column headers */
if (!Frames_libflags) {
reframewins();