buf = realloc (path, strlen (path) + 1);
buf = realloc (path, (size_t) retval);
__getcwd (char *buf, size_t size){  int save_errno;  char *path;  int n;  char *result;  size_t alloc_size = size;  if (no_syscall_getcwd && no_new_dcache)    return generic_getcwd (buf, size);  if (size == 0)    {      if (buf != NULL)	{	  __set_errno (EINVAL);	  return NULL;	}      alloc_size = PATH_MAX + 1;    }  if (buf != NULL)    path = buf;  else    {      path = malloc (alloc_size);      if (path == NULL)	return NULL;    }  save_errno = errno;#ifdef __NR_getcwd  if (!no_syscall_getcwd)    {      int retval;      retval = __syscall_getcwd (path, alloc_size);      if (retval >= 0)	{	  if (buf == NULL)	    {	      buf = realloc (path, strlen (path) + 1);	      if (buf == NULL)		/* `relloc' failed but we still have the original string.  */		buf = path;	    }	  return buf;	}      if (errno == ENOSYS)	{	   no_syscall_getcwd = 1;	   no_new_dcache = 0;	/* Now we will try the /proc method.  */	}      else if (errno != ERANGE || buf != NULL)	{	  if (buf == NULL)	    free (path);	  return NULL;	}      __set_errno (save_errno);    }#endif  n = __readlink ("/proc/self/cwd", path, alloc_size - 1);  if (n != -1)    {      if (path[0] == '/')	{	  if (n >= alloc_size - 1)	    {	      if (buf == NULL)		free (path);	      return NULL;	    }	  path[n] = '\0';	  if (buf == NULL)	    {	      buf = realloc (path, (size_t) n + 1);	      if (buf == NULL)		/* `relloc' failed but we still have the original string.  */		buf = path;	    }	  return buf;	}      else	no_new_dcache = 1;    }  /* Set to no_new_dcache only if error indicates that proc doesn't exist.  */  if (errno != EACCES && errno != ENAMETOOLONG)    no_new_dcache = 1;  /* Something went wrong.  Restore the error number and use the generic     version.  */  __set_errno (save_errno);  /* Don't put restrictions on the length of the path unless the user does.  */  if (size == 0)    {      free (path);      path = NULL;    }  result = generic_getcwd (path, size);  if (result == NULL && buf == NULL && size != 0)    free (path);  return result;}