diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-10 16:10:01 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-03 11:02:06 -0800 |
commit | 81e46cab5f4bdd69fa0a644dba86f6902cece175 (patch) | |
tree | 3f664cb6d78c4a2cccbe9ef2be153e3df9633fc9 /geometry.c | |
parent | a1551b78e9ac0e2075ca241c0e8ae361758f26b4 (diff) |
Use asprintf() if the platform supports it
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'geometry.c')
-rw-r--r-- | geometry.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -3263,7 +3263,6 @@ FontFromParts(Atom fontTok, Atom slantTok, Atom setWidthTok, Atom varTok, int size, Atom encodingTok) { - int totalSize; const char *font, *weight, *slant, *setWidth, *variant, *encoding; char *rtrn; @@ -3282,7 +3281,13 @@ FontFromParts(Atom fontTok, None ? XkbAtomGetString(NULL, encodingTok) : DFLT_ENCODING); if (size == 0) size = DFLT_SIZE; - totalSize = + +#ifdef HAVE_ASPRINTF + if (asprintf(&rtrn, FONT_TEMPLATE, font, weight, slant, + setWidth, variant, size, encoding) < 0) + rtrn = NULL; +#else + size_t totalSize = strlen(FONT_TEMPLATE) + strlen(font) + strlen(weight) + strlen(slant); totalSize += strlen(setWidth) + strlen(variant) + strlen(encoding); rtrn = calloc(totalSize, 1); @@ -3291,6 +3296,7 @@ FontFromParts(Atom fontTok, snprintf(rtrn, totalSize, FONT_TEMPLATE, font, weight, slant, setWidth, variant, size, encoding); } +#endif return rtrn; } |