Changeset 1765 in MondoRescue for branches/2.2.5/mindi-busybox/libbb/xgetcwd.c


Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/libbb/xgetcwd.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * xgetcwd.c -- return current directory with unlimited length
     
    78*/
    89
    9 #include <stdlib.h>
    10 #include <errno.h>
    11 #include <unistd.h>
    12 #include <limits.h>
    13 #include <sys/param.h>
    1410#include "libbb.h"
    1511
     
    2319
    2420char *
    25 xgetcwd (char *cwd)
     21xrealloc_getcwd_or_warn(char *cwd)
    2622{
    27   char *ret;
    28   unsigned path_max;
     23    char *ret;
     24    unsigned path_max;
    2925
    30   path_max = (unsigned) PATH_MAX;
    31   path_max += 2;                /* The getcwd docs say to do this. */
     26    path_max = (unsigned) PATH_MAX;
     27    path_max += 2;                /* The getcwd docs say to do this. */
    3228
    33   if(cwd==0)
    34     cwd = xmalloc (path_max);
     29    if (cwd == NULL)
     30        cwd = xmalloc(path_max);
    3531
    36   while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) {
    37       path_max += PATH_INCR;
    38       cwd = xrealloc (cwd, path_max);
    39   }
     32    while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) {
     33        path_max += PATH_INCR;
     34        cwd = xrealloc(cwd, path_max);
     35    }
    4036
    41   if (ret == NULL) {
    42       free (cwd);
    43       bb_perror_msg("getcwd()");
    44       return NULL;
    45   }
     37    if (ret == NULL) {
     38        free(cwd);
     39        bb_perror_msg("getcwd");
     40        return NULL;
     41    }
    4642
    47   return cwd;
     43    return cwd;
    4844}
Note: See TracChangeset for help on using the changeset viewer.