This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "xalloc.h"
#include "xreadlink.h"
/* Call readlink to get the symbolic link value of FILENAME.
Return a pointer to that NUL-terminated string in malloc'd storage.
If readlink fails, return NULL (caller may use errno to diagnose).
#include "xalloc.h"
#include "xreadlink.h"
/* Call readlink to get the symbolic link value of FILENAME.
Return a pointer to that NUL-terminated string in malloc'd storage.
If readlink fails, return NULL (caller may use errno to diagnose).
{
/* The initial buffer size for the link value. A power of 2
detects arithmetic overflow earlier, but is not required. */
size_t buf_size = 128;
{
/* The initial buffer size for the link value. A power of 2
detects arithmetic overflow earlier, but is not required. */
size_t buf_size = 128;
- int link_length;
- buffer = (char *) xrealloc (buffer, buf_size);
- link_length = readlink (filename, buffer, buf_size);
+ char *buffer = xmalloc (buf_size);
+ ssize_t link_length = readlink (filename, buffer, buf_size);
+