mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
port a few things over to use xmalloc and friends instead of low-level libc malloc/free directly
This commit is contained in:
parent
ab5ac06ac7
commit
a0f01ddc95
2 changed files with 11 additions and 12 deletions
|
|
@ -2223,7 +2223,7 @@ int pa_close_all(int except_fd, ...) {
|
|||
va_end(ap);
|
||||
|
||||
r = pa_close_allv(p);
|
||||
free(p);
|
||||
pa_xfree(p);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,21 +60,20 @@ static char *get_cpuinfo(void) {
|
|||
char *cpuinfo;
|
||||
int n, fd;
|
||||
|
||||
if (!(cpuinfo = malloc(MAX_BUFFER)))
|
||||
return NULL;
|
||||
cpuinfo = pa_xmalloc(MAX_BUFFER);
|
||||
|
||||
if ((fd = open("/proc/cpuinfo", O_RDONLY)) < 0) {
|
||||
free (cpuinfo);
|
||||
pa_xfree(cpuinfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((n = read(fd, cpuinfo, MAX_BUFFER-1)) < 0) {
|
||||
free (cpuinfo);
|
||||
close (fd);
|
||||
if ((n = pa_read(fd, cpuinfo, MAX_BUFFER-1)) < 0) {
|
||||
pa_xfree(cpuinfo);
|
||||
pa_close(fd);
|
||||
return NULL;
|
||||
}
|
||||
cpuinfo[n] = 0;
|
||||
close (fd);
|
||||
pa_close(fd);
|
||||
|
||||
return cpuinfo;
|
||||
}
|
||||
|
|
@ -102,7 +101,7 @@ void pa_cpu_init_arm (void) {
|
|||
if (arch >= 7)
|
||||
flags |= PA_CPU_ARM_V7;
|
||||
|
||||
free (line);
|
||||
pa_xfree(line);
|
||||
}
|
||||
/* get the CPU features */
|
||||
if ((line = get_cpuinfo_line (cpuinfo, "Features"))) {
|
||||
|
|
@ -118,10 +117,10 @@ void pa_cpu_init_arm (void) {
|
|||
else if (!strcmp (current, "vfpv3"))
|
||||
flags |= PA_CPU_ARM_VFPV3;
|
||||
|
||||
free (current);
|
||||
pa_xfree(current);
|
||||
}
|
||||
}
|
||||
free (cpuinfo);
|
||||
pa_xfree(cpuinfo);
|
||||
|
||||
pa_log_info ("CPU flags: %s%s%s%s%s%s",
|
||||
(flags & PA_CPU_ARM_V6) ? "V6 " : "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue