mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
add, then use, xvasprintf, checking for appropriate return.
This commit is contained in:
parent
2fc191f978
commit
83de84b7f8
2
calmwm.h
2
calmwm.h
@ -598,5 +598,7 @@ char *xstrdup(const char *);
|
||||
int xasprintf(char **, const char *, ...)
|
||||
__attribute__((__format__ (printf, 2, 3)))
|
||||
__attribute__((__nonnull__ (2)));
|
||||
int xvasprintf(char **, const char *, va_list)
|
||||
__attribute__((__nonnull__ (2)));
|
||||
|
||||
#endif /* _CALMWM_H_ */
|
||||
|
5
screen.c
5
screen.c
@ -275,15 +275,12 @@ void
|
||||
screen_prop_win_draw(struct screen_ctx *sc, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int i;
|
||||
char *text;
|
||||
XGlyphInfo extents;
|
||||
|
||||
va_start(ap, fmt);
|
||||
i = vasprintf(&text, fmt, ap);
|
||||
xvasprintf(&text, fmt, ap);
|
||||
va_end(ap);
|
||||
if (i < 0 || text == NULL)
|
||||
err(1, "vasprintf");
|
||||
|
||||
XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)text,
|
||||
strlen(text), &extents);
|
||||
|
17
xmalloc.c
17
xmalloc.c
@ -91,11 +91,20 @@ xasprintf(char **ret, const char *fmt, ...)
|
||||
int i;
|
||||
|
||||
va_start(ap, fmt);
|
||||
i = vasprintf(ret, fmt, ap);
|
||||
i = xvasprintf(ret, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (i < 0 || *ret == NULL)
|
||||
err(1, "asprintf");
|
||||
|
||||
return(i);
|
||||
}
|
||||
|
||||
int
|
||||
xvasprintf(char **ret, const char *fmt, va_list ap)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = vasprintf(ret, fmt, ap);
|
||||
if (i == -1)
|
||||
err(1, "vasprintf");
|
||||
|
||||
return(i);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user