]> granicus.if.org Git - graphviz/commit
add sprintf-like helper
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 23 Apr 2021 01:29:21 +0000 (18:29 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 29 Apr 2021 14:59:33 +0000 (07:59 -0700)
commit08786bbb19bbe0fdf28adcbb305b02f54a237edf
tree3042f3829fb7380a58617edf40b208f5f915ba1a
parent3d945e7b739c8cfae38490d4b631460f5cb463de
add sprintf-like helper

The function sprintf is generally considered unsafe to use in modern C. In the
Graphviz code base, its uses are slowly being replaced with safer alternatives
(#1950). However, the alternative code is frequently overly verbose and
counter-intuitive. This commit adds (hopefully) convenient alternative functions
that can be used to replace sprintf uses. The gv_sprint function is similar to
the GNU asprintf function with a different calling convention.

The tests added alongside follow the same strategy as used for testing
lib/vmalloc.
lib/cgraph/Makefile.am
lib/cgraph/cgraph.vcxproj
lib/cgraph/cgraph.vcxproj.filters
lib/cgraph/sprint.c [new file with mode: 0644]
lib/cgraph/sprint.h [new file with mode: 0644]
lib/cgraph/test_sprint.c [new file with mode: 0644]
rtest/test_sprint.py [new file with mode: 0644]