mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
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:
parent
c6ea9fecc9
commit
49fd8ee72e
7 changed files with 119 additions and 38 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue