From 6437e1535c7da1cb97fd215131c4bd92c60021fe Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 22 Apr 2021 18:48:41 -0700 Subject: [PATCH] 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. --- lib/sparse/DotIO.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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); } -- 2.40.0