core-util: replace remaining fixed size destination string functions by _malloc() versions

This helps portability to GNU/Hurd.

Patch originally from Samuel Thibault but modified.

Closes ticket #546
This commit is contained in:
Lennart Poettering 2009-08-01 02:03:22 +02:00
parent c6ea9fecc9
commit 49fd8ee72e
7 changed files with 119 additions and 38 deletions

View file

@ -23,12 +23,33 @@
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <pulse/util.h>
#include <pulse/xmalloc.h>
int main(int argc, char *argv[]) {
char exename[PATH_MAX];
char *exename;
size_t allocated = 128;
for (;;) {
exename = pa_xmalloc(allocated);
if (!pa_get_binary_name(exename, allocated)) {
printf("failed to read binary name\n");
pa_xfree(exename);
break;
}
if (strlen(exename) < allocated - 1) {
printf("%s\n", exename);
pa_xfree(exename);
break;
}
pa_xfree(exename);
allocated *= 2;
}
printf("%s\n", pa_get_binary_name(exename, sizeof(exename)));
return 0;
}