summaryrefslogtreecommitdiff
path: root/psgeom.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-27 20:55:33 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-27 20:55:37 -0700
commitbfb6044479e8e974e848f47969f75b84865fea13 (patch)
treed8631e32a64744389b9c6e2291ff901f771c0745 /psgeom.c
parent7848ba1d292f55553058c1f17596baa1094cdae5 (diff)
Replace several malloc+sprintf pairs with asprintf() calls
Includes fallback uAsprintf() for systems without asprintf yet Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'psgeom.c')
-rw-r--r--psgeom.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/psgeom.c b/psgeom.c
index 4ec1347..94c178a 100644
--- a/psgeom.c
+++ b/psgeom.c
@@ -26,6 +26,10 @@
********************************************************/
/* $XFree86: xc/programs/xkbprint/psgeom.c,v 1.5 2001/07/25 15:05:25 dawes Exp $ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#define XK_TECHNICAL
#define XK_PUBLISHING
#define XK_KATAKANA
@@ -869,11 +873,9 @@ PSPageTrailer(FILE *out, PSState *state)
if (sName == NULL)
sName = "(unknown)";
- lbuf = malloc(10 + strlen(sName));
- if (!lbuf) {
+ if (asprintf(&lbuf, "Layout: %s", sName) == -1) {
uFatalError("Can't allocate memory for string\n");
}
- sprintf(lbuf, "Layout: %s", sName);
fprintf(out, "kbx kbdscalewidth 0 (%s) centeroffset pop add\n",
lbuf);
fprintf(out, " kby kbdscaleheight add %d add\n", baseline);
@@ -904,11 +906,9 @@ PSPageTrailer(FILE *out, PSState *state)
if (sName == NULL)
sName = "(unknown)";
- lbuf = malloc(12 + strlen(sName));
- if (!lbuf) {
+ if (asprintf(&lbuf, "Keycodes: %s", sName) == -1) {
uFatalError("Can't allocate memory for string\n");
}
- sprintf(lbuf, "Keycodes: %s", sName);
fprintf(out, "kbx kbdscalewidth 0 (%s) centeroffset pop add\n",
lbuf);
fprintf(out, " kby kbdscaleheight add %d add\n", baseline);