]> granicus.if.org Git - graphviz/commit
gvc auto_output_filename: avoid 'strdup' when constructing file name
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 9 Jul 2022 16:05:41 +0000 (09:05 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 22 Jul 2022 00:41:57 +0000 (17:41 -0700)
commit4291cc769a3eeef8b1c171e5479194733a4da6cd
tree653bdfa8926627ded224f11b86a5123d93d741a2
parent3124dcdd2c947b0ff601ba11013965f3cf565f65
gvc auto_output_filename: avoid 'strdup' when constructing file name

This block of code is scanning a string of `:`-separated entries and writing
them into `buf` in reverse order `.`-separated. We can rewrite it to avoid
dynamic allocation, thus avoiding certain failure cases and locking overhead.

Unfortunately there seems to be no variant of `strrchr` that takes a length. So
we need to write our own loop for locating the last `:` with a limit.
lib/gvc/gvdevice.c