misc/ss: simplify buffer realloc, fix checking realloc failure
Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
parent
e0dce0e5dc
commit
532ca40a52
|
|
@ -550,7 +550,7 @@ static int find_entry(unsigned ino, char **buf, int type)
|
||||||
struct user_ent *p;
|
struct user_ent *p;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char **new_buf = buf;
|
char *new_buf;
|
||||||
int len, new_buf_len;
|
int len, new_buf_len;
|
||||||
int buf_used = 0;
|
int buf_used = 0;
|
||||||
int buf_len = 0;
|
int buf_len = 0;
|
||||||
|
|
@ -592,12 +592,12 @@ static int find_entry(unsigned ino, char **buf, int type)
|
||||||
|
|
||||||
if (len < 0 || len >= buf_len - buf_used) {
|
if (len < 0 || len >= buf_len - buf_used) {
|
||||||
new_buf_len = buf_len + ENTRY_BUF_SIZE;
|
new_buf_len = buf_len + ENTRY_BUF_SIZE;
|
||||||
*new_buf = realloc(*buf, new_buf_len);
|
new_buf = realloc(*buf, new_buf_len);
|
||||||
if (!new_buf) {
|
if (!new_buf) {
|
||||||
fprintf(stderr, "ss: failed to malloc buffer\n");
|
fprintf(stderr, "ss: failed to malloc buffer\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
*buf = *new_buf;
|
*buf = new_buf;
|
||||||
buf_len = new_buf_len;
|
buf_len = new_buf_len;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue