[systemd-devel] [PATCH 1/2] RFC: util: Avoid memory allocations for formatting paths

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Apr 2 14:04:13 PDT 2013


On Tue, Apr 02, 2013 at 10:35:50PM +0200, Holger Freyther wrote:
> +#define format_procfs_path(buffer, path, pid) \
> +        snprintf(buffer, sizeof(buffer) - 1, "/proc/%lu/%s", (unsigned long) pid, path); \
> +        char_array_0(buffer);
> +
Hi,
Lennart recently implemented a smarter way to do those short printfs:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=fa70beaabc56762fdf77e675c3e09bb638d89938.
No need to use PATH_MAX.

Zbyszek


More information about the systemd-devel mailing list