Browse Source

Use asprintf(3) and avoid manual allocation

master
lostd 10 years ago
parent
commit
3459f6a5e7
1 changed files with 1 additions and 4 deletions
  1. +1
    -4
      noice.c

+ 1
- 4
noice.c View File

@@ -341,7 +341,6 @@ nochange:
} }
if (ret == 3) { if (ret == 3) {
char *pathnew, *pathtmp; char *pathnew, *pathtmp;
size_t pathsiz;
char *name; char *name;
u_int8_t type; u_int8_t type;
char *bin; char *bin;
@@ -355,9 +354,7 @@ nochange:
name = dents[cur].d_name; name = dents[cur].d_name;
type = dents[cur].d_type; type = dents[cur].d_type;


pathsiz = strlen(path) + 1 + strlen(name) + 1;
pathnew = malloc(pathsiz);
snprintf(pathnew, pathsiz, "%s/%s", path, name);
asprintf(&pathnew, "%s/%s", path, name);


DPRINTF_S(name); DPRINTF_S(name);
DPRINTF_U(type); DPRINTF_U(type);


Loading…
Cancel
Save