summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-04-06 10:05:59 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-08 15:26:32 +0200
commitab7d9b674e8eb1388dff4d44def1b661892832e6 (patch)
tree240db615184028e12ff1743389625c6151dfb752 /src/boot
parentb6b7d4337976eeac610b9ed2c3e1fd596a247b14 (diff)
util: Avoid memory allocations for formatting paths
Avoid memory allocations to construct the path for files in the procfs. The procfs paths are way shorter than the PATH_MAX so we can use snprintf on a string located on the stack. This shows up as a win on x86 using the benchmark program below. $ make libsystemd-shared.la; gcc -O2 -Isrc/systemd/ -Isrc/ \ -o simple-perf-test simple-perf-test.c \ .libs/libsystemd-shared.a -lrt #include "shared/util.h" void test_once(void) { pid_t pid = getpid(); char *tmp = NULL; get_process_comm(pid, &tmp); free(tmp); tmp = NULL; get_process_cmdline(pid, 0, 1, &tmp); free(tmp); is_kernel_thread(pid); tmp = NULL; get_process_exe(pid, &tmp); free(tmp); } int main(int argc, char **argv) { int i; for (i = 0; i < 50000; ++i) test_once(); }
Diffstat (limited to 'src/boot')
0 files changed, 0 insertions, 0 deletions