aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert2011-03-31 23:28:48 -0700
committerPaul Eggert2011-03-31 23:28:48 -0700
commitd1fdcab7425f36a34ddeaf304e2c6e3c471ba8db (patch)
treef59643a560ce58433a9a92dfe615dd18aecc0457 /src/sysdep.c
parent63139bfa89692ec666815f57d0658996577a80d3 (diff)
downloademacs-d1fdcab7425f36a34ddeaf304e2c6e3c471ba8db.tar.gz
emacs-d1fdcab7425f36a34ddeaf304e2c6e3c471ba8db.zip
Replace two copies of readlink code with single gnulib version.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 1bb400421f0..a165a9ca52f 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -31,6 +31,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#endif /* HAVE_LIMITS_H */ 31#endif /* HAVE_LIMITS_H */
32#include <unistd.h> 32#include <unistd.h>
33 33
34#include <allocator.h>
35#include <careadlinkat.h>
34#include <ignore-value.h> 36#include <ignore-value.h>
35 37
36#include "lisp.h" 38#include "lisp.h"
@@ -1866,6 +1868,22 @@ emacs_write (int fildes, const char *buf, unsigned int nbyte)
1866 } 1868 }
1867 return (bytes_written); 1869 return (bytes_written);
1868} 1870}
1871
1872static struct allocator const emacs_norealloc_allocator =
1873 { xmalloc, NULL, xfree, memory_full };
1874
1875/* Get the symbolic link value of FILENAME. Return a pointer to a
1876 NUL-terminated string. If readlink fails, return NULL and set
1877 errno. If the value fits in INITIAL_BUF, return INITIAL_BUF.
1878 Otherwise, allocate memory and return a pointer to that memory. If
1879 memory allocation fails, diagnose and fail without returning. If
1880 successful, store the length of the symbolic link into *LINKLEN. */
1881char *
1882emacs_readlink (char const *filename, char initial_buf[READLINK_BUFSIZE])
1883{
1884 return careadlinkat (AT_FDCWD, filename, initial_buf, READLINK_BUFSIZE,
1885 &emacs_norealloc_allocator, careadlinkatcwd);
1886}
1869 1887
1870#ifdef USG 1888#ifdef USG
1871/* 1889/*