Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
long symlink_max;
size_t bufsize;
char *buf;
ssize_t len;

errno = 0;
if ((symlink_max = pathconf("/usr/bin/", _PC_SYMLINK_MAX)) 
     == -1 && errno != 0) 
{
    /* handle error condition */
}
if (symlink_max == -1)
    bufsize = 10000;
else
    bufsize = symlink_max+1;

if ((buf = (char *)malloc(bufsize)) == NULL) {
    /* handle error condition */
}

len = readlink("/usr/bin/perl", buf, bufsize);
buf[len] = '\0';

...

Code Block
bgColor#ccccff
enum { BUFFERSIZE = 1024 };
char buf[BUFFERSIZE];
ssize_t len;

if ((len = readlink("/usr/bin/perl", buf, sizeof(buf)-1)) 
     != -1)
{
    buf[len] = '\0';
}
else {
   /* handle error condition */
}

...