char *filename = NULL;
struct stat statbuf;
volatile bool do_rename = false;
- int fd;
+ int fd, sz;
if (!p->path) {
if (overwrite)
UCI_THROW(ctx, UCI_ERR_INVAL);
}
- if ((asprintf(&filename, "%s/.%s.uci-XXXXXX", ctx->confdir, p->e.name) < 0) || !filename)
- UCI_THROW(ctx, UCI_ERR_MEM);
+ sz = snprintf(NULL, 0, "%s/.%s.uci-XXXXXX", ctx->confdir, p->e.name);
+ filename = alloca(sz + 1);
+ snprintf(filename, sz + 1, "%s/.%s.uci-XXXXXX", ctx->confdir, p->e.name);
/* open the config file for writing now, so that it is locked */
f1 = uci_open_stream(ctx, p->path, NULL, SEEK_SET, true, true);
}
free(path);
}
- free(filename);
if (ctx->err)
UCI_THROW(ctx, ctx->err);
}