mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
fee1863c83
The `sd_path_lookup(3)` man page states that the returned string shall be `free(3)`'d but then doesn't do so in the example code. Also add basic error handling as well.
18 lines
265 B
C
18 lines
265 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sd-path.h>
|
|
|
|
int main(void) {
|
|
int r;
|
|
char *t;
|
|
|
|
r = sd_path_lookup(SD_PATH_USER_DOCUMENTS, NULL, &t);
|
|
if (r < 0)
|
|
return EXIT_FAILURE;
|
|
|
|
printf("~/Documents: %s\n", t);
|
|
free(t);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|