From 65e47bc25f033afd627d5f25daf5f1833aa4922b Mon Sep 17 00:00:00 2001
From: Bastien ROUCARIES
Date: Tue, 11 Jan 2011 13:05:54 +0100
Subject: [PATCH 2/3] Use malloc instead of xmalloc in openat-proc
Use malloc instead of xmalloc in openat-proc. In case of faillure, all caller fall back to slow fdir path.
---
lib/openat-proc.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index 51a8aa2..5868e5d 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -26,13 +26,14 @@
#include
#include
+#include
+
#include
#include
#include "dirname.h"
#include "intprops.h"
#include "same-inode.h"
-#include "xalloc.h"
/* The results of open() in this file are not used with fchdir,
and we do not leak fds to any single-threaded code that could use stdio,
@@ -42,6 +43,9 @@
#undef open
#undef close
+/* use system definition of malloc here allocation is alway > 1 */
+#undef malloc
+
#define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s"
#define PROC_SELF_FD_NAME_SIZE_BOUND(len) \
@@ -98,7 +102,7 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
else
{
size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file));
- char *result = (bufsize < OPENAT_BUFFER_SIZE ? buf : xmalloc (bufsize));
+ char *result = (bufsize < OPENAT_BUFFER_SIZE ? buf : malloc (bufsize));
sprintf (result, PROC_SELF_FD_FORMAT, fd, file);
return result;
}
--
1.7.1