projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
man: use default MANPATH of "/usr/man"; do not search paths twice
[oweals/busybox.git]
/
libbb
/
procps.c
diff --git
a/libbb/procps.c
b/libbb/procps.c
index 7d49d83ce6561663c0e12f7cbeec966585563507..fd19621db00be01eedf72d2402ad2875abadbc7d 100644
(file)
--- a/
libbb/procps.c
+++ b/
libbb/procps.c
@@
-46,7
+46,7
@@
static int get_cached(cache_t *cp, unsigned id)
if (cp->cache[i].id == id)
return i;
i = cp->size++;
if (cp->cache[i].id == id)
return i;
i = cp->size++;
- cp->cache = xrealloc
(cp->cache, cp->size * sizeof(*cp->cache)
);
+ cp->cache = xrealloc
_vector(cp->cache, 2, i
);
cp->cache[i++].id = id;
return -i;
}
cp->cache[i++].id = id;
return -i;
}
@@
-60,7
+60,7
@@
static char* get_cached(cache_t *cp, unsigned id, ug_func* fp)
if (cp->cache[i].id == id)
return cp->cache[i].name;
i = cp->size++;
if (cp->cache[i].id == id)
return cp->cache[i].name;
i = cp->size++;
- cp->cache = xrealloc
(cp->cache, cp->size * sizeof(*cp->cache)
);
+ cp->cache = xrealloc
_vector(cp->cache, 2, i
);
cp->cache[i].id = id;
/* Never fails. Generates numeric string if name isn't found */
fp(cp->cache[i].name, sizeof(cp->cache[i].name), id);
cp->cache[i].id = id;
/* Never fails. Generates numeric string if name isn't found */
fp(cp->cache[i].name, sizeof(cp->cache[i].name), id);
@@
-78,7
+78,7
@@
const char* FAST_FUNC get_cached_groupname(gid_t gid)
#define PROCPS_BUFSIZE 1024
#define PROCPS_BUFSIZE 1024
-static int
FAST_FUNC
read_to_buf(const char *filename, void *buf)
+static int read_to_buf(const char *filename, void *buf)
{
int fd;
/* open_read_close() would do two reads, checking for EOF.
{
int fd;
/* open_read_close() would do two reads, checking for EOF.
@@
-308,7
+308,7
@@
procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
FILE *file;
strcpy(filename_tail, "/smaps");
FILE *file;
strcpy(filename_tail, "/smaps");
- file = fopen
(filename, "r"
);
+ file = fopen
_for_read(filename
);
if (!file)
break;
while (fgets(buf, sizeof(buf), file)) {
if (!file)
break;
while (fgets(buf, sizeof(buf), file)) {
@@
-385,16
+385,15
@@
procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
n = read_to_buf(filename, buf);
if (n <= 0)
break;
n = read_to_buf(filename, buf);
if (n <= 0)
break;
-#if ENABLE_PGREP || ENABLE_PKILL
if (flags & PSSCAN_ARGVN) {
if (flags & PSSCAN_ARGVN) {
- do {
- n--;
- if (buf[n] == '\0')
- buf[n] = ' ';
- } while (n);
+ sp->argv_len = n;
+ sp->argv0 = xmalloc(n + 1);
+ memcpy(sp->argv0, buf, n + 1);
+ /* sp->argv0[n] = '\0'; - buf has it */
+ } else {
+ sp->argv_len = 0;
+ sp->argv0 = xstrdup(buf);
}
}
-#endif
- sp->argv0 = xstrdup(buf);
}
#endif
break;
}
#endif
break;