mirror of
https://github.com/pikami/slstatus.git
synced 2024-11-30 15:25:41 +00:00
used a different implementation of smprintf() imported from dwmstatus
This commit is contained in:
parent
94a62b864b
commit
5829cee24e
22
slstatus.c
22
slstatus.c
@ -79,17 +79,23 @@ static char *
|
|||||||
smprintf(const char *fmt, ...)
|
smprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char tmp[120];
|
char *ret;
|
||||||
char *ret = NULL;
|
int len;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(tmp, sizeof(tmp)-1, fmt, ap);
|
len = vsnprintf(NULL, 0, fmt, ap);
|
||||||
tmp[strlen(tmp)+1] = '\0';
|
|
||||||
|
|
||||||
if (asprintf(&ret, "%s", tmp) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
ret = malloc(++len);
|
||||||
|
if (ret == NULL) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(ret, len, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user