+2016-08-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ getdelim: remove dependency on realloc-posix
+ * lib/canonicalize-lgpl.c (alloc_failed)
+ [!FUNC_REALPATH_WORKS || defined _LIBC]: New function,
+ (__realpath) [!FUNC_REALPATH_WORKS || defined _LIBC]: Use it.
+ Use __set_errno where needed, for consistency.
+ * lib/getdelim.c (alloc_failed): New function.
+ (getdelim): Use it.
+
2016-08-09 Assaf Gordon <assafgordon@gmail.com>
parse-datetime: add optional debug printing
#endif
#if !FUNC_REALPATH_WORKS || defined _LIBC
+
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the malloc or realloc modules; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Return the canonical absolute name of file NAME. A canonical name
does not contain any ".", ".." components nor any repeated path
separators ('/') or symlinks. All path components must exist. If
rpath = malloc (path_max);
if (rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'malloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
return NULL;
}
}
new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'realloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
goto error;
}
rpath = new_rpath;
buf = malloca (path_max);
if (!buf)
{
- errno = ENOMEM;
+ alloc_failed ();
goto error;
}
{
int saved_errno = errno;
freea (buf);
- errno = saved_errno;
+ __set_errno (saved_errno);
goto error;
}
buf[n] = '\0';
if (!extra_buf)
{
freea (buf);
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
}
freea (extra_buf);
if (resolved == NULL)
free (rpath);
- errno = saved_errno;
+ __set_errno (saved_errno);
}
return NULL;
}
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
#endif
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the realloc module; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
NULL), pointing to *N characters of space. It is realloc'ed as
new_lineptr = (char *) realloc (*lineptr, *n);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
stdio
extensions
stdint [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
-realloc-posix [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
errno [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
configure.ac: