From: Matthew Fernandez Date: Fri, 23 Apr 2021 01:48:41 +0000 (-0700) Subject: replace a use of snprintf pattern with gv_sprint X-Git-Tag: 2.47.2~38^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6437e1535c7da1cb97fd215131c4bd92c60021fe;p=graphviz replace a use of snprintf pattern with gv_sprint This commit serves as an example of how to use the functionality added in the previous commit. Related to #1950. --- diff --git a/lib/sparse/DotIO.c b/lib/sparse/DotIO.c index 36d454794..8bfe6d043 100644 --- a/lib/sparse/DotIO.c +++ b/lib/sparse/DotIO.c @@ -9,6 +9,7 @@ *************************************************************************/ #define STANDALONE +#include #include #include #include @@ -604,10 +605,7 @@ char *cat_string(char *s1, char *s2){ } static char *cat_string3(char *s1, char *s2, char *s3, int id){ - size_t len = (size_t)snprintf(NULL, 0, "%s|%s|%s|%d", s1, s2, s3, id) + 1; - char *s = malloc(sizeof(char) * len); - snprintf(s, len, "%s|%s|%s|%d", s1, s2, s3, id); - return s; + return gv_sprint_or_exit("%s|%s|%s|%d", s1, s2, s3, id); }