git/contrib/coccinelle/xstrdup_or_null.cocci
René Scharfe b1edb40f25 abspath: add absolute_pathdup()
Add a function that returns a buffer containing the absolute path of its
argument and a semantic patch for its intended use.  It avoids an extra
string copy to a static buffer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-01-26 14:51:06 -08:00

13 lines
161 B
Text

@@
expression E;
expression V;
@@
- if (E)
- V = xstrdup(E);
+ V = xstrdup_or_null(E);
@@
expression E;
@@
- xstrdup(absolute_path(E))
+ absolute_pathdup(E)