]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: standard: add a memprintf() function to build formatted error messages
authorWilly Tarreau <w@1wt.eu>
Fri, 27 Apr 2012 09:16:50 +0000 (11:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 30 Apr 2012 09:55:35 +0000 (11:55 +0200)
commit9a7bea52b12b612e83524037d20b941d1d97cfc4
treeaaddc3542108ba7c52b1addd512096b73dc53b11
parentb56928a74cfb8288e1d2246b9350e39d491a3236
MINOR: standard: add a memprintf() function to build formatted error messages

memprintf() is just like snprintf() except that it always returns a properly
sized allocated string that the caller is responsible for freeing. NULL is
returned on serious errors. It also supports stackable calls over the same
pointer since it offers support for automatically freeing a previous one :

     memprintf(&err, "invalid argument: '%s'", arg);
     ...
     memprintf(&err, "keyword parser said: <%s>", *err);
     ...
     memprintf(&err, "line parser said: %s\n", *err);
     ...
     free(*err);
include/common/standard.h
src/standard.c