bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] valloc()?


From: Derek Price
Subject: Re: [bug-gnulib] valloc()?
Date: Thu, 03 Mar 2005 10:26:02 -0500
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Bruno Haible wrote:

Do you still see some nits that could be improved?



Patch attached for three nits:

   - Remove unnecessary fd set.
   - Rename macro gl_FUNC_MMAP to gl_FUNC_MMAP_ANON to sync
     with new m4 file name.
   - Comment in header says pagealign_alloc() may return NULL.  It may
not -
     it will exit via error() instead.


And one question:

Why do you cast to char * here, when ret is actually a void *?  Is this
necessary?

 void *unaligned_ptr = xmalloc (size + pagesize - 1);
 ret = (char *) unaligned_ptr
       + ((- (unsigned long) unaligned_ptr) & (pagesize - 1));


2005-03-03  Derek R. Price  <address@hidden>

   * lib/pagealign_alloc.c (pagealign_alloc): Remove unnecessary
assignment.
   * lib/pagealign_alloc.h (pagealign_alloc): Correct comment.
   * m4/mmap-anon.m4 (gl_FUNC_MMAP): Rename to...
   (gl_FUNC_MMAP_ANON): ...this.
   * m4/pagealign_alloc.m4 (gl_PREREQ_PAGEALIGN_ALLOC): Use new mmap
macro name.

Regards,

Derek
Index: lib/pagealign_alloc.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/pagealign_alloc.c,v
retrieving revision 1.1
diff -u -p -r1.1 pagealign_alloc.c
--- lib/pagealign_alloc.c       3 Mar 2005 14:07:04 -0000       1.1
+++ lib/pagealign_alloc.c       3 Mar 2005 15:20:16 -0000
@@ -122,7 +122,6 @@ pagealign_alloc (size_t size)
                          number of open file descriptors.  */
 # ifdef HAVE_MAP_ANONYMOUS
   flags = MAP_ANONYMOUS | MAP_PRIVATE;
-  fd = -1;
 # else /* !HAVE_MAP_ANONYMOUS */
   flags = MAP_FILE | MAP_PRIVATE;
   if (fd == -1)
Index: lib/pagealign_alloc.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/pagealign_alloc.h,v
retrieving revision 1.1
diff -u -p -r1.1 pagealign_alloc.h
--- lib/pagealign_alloc.h       3 Mar 2005 14:07:04 -0000       1.1
+++ lib/pagealign_alloc.h       3 Mar 2005 15:20:16 -0000
@@ -26,8 +26,8 @@
    boundary.
    If SIZE is not a multiple of the system page size, it will be rounded up
    to the next multiple.
-   Return a pointer to the start of the memory block, or NULL if the allocation
-   failed.  */
+   Return a pointer to the start of the memory block, or fail with an error
+   message via error() if the allocation failed.  */
 extern void *pagealign_alloc (size_t size);

 /* Free a memory block.
Index: m4/mmap-anon.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/mmap-anon.m4,v
retrieving revision 1.1
diff -u -p -r1.1 mmap-anon.m4
--- m4/mmap-anon.m4     3 Mar 2005 14:07:04 -0000       1.1
+++ m4/mmap-anon.m4     3 Mar 2005 15:20:16 -0000
@@ -4,7 +4,7 @@ dnl This file is free software; the Free
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.

-AC_DEFUN([gl_FUNC_MMAP],
+AC_DEFUN([gl_FUNC_MMAP_ANON],
 [
   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
   AC_REQUIRE([AC_PROG_CPP])
Index: m4/pagealign_alloc.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/pagealign_alloc.m4,v
retrieving revision 1.1
diff -u -p -r1.1 pagealign_alloc.m4
--- m4/pagealign_alloc.m4       3 Mar 2005 14:07:04 -0000       1.1
+++ m4/pagealign_alloc.m4       3 Mar 2005 15:20:16 -0000
@@ -17,7 +17,7 @@ AC_DEFUN([gl_PAGEALIGN_ALLOC],
 # Prerequisites of lib/pagealign_alloc.c.
 AC_DEFUN([gl_PREREQ_PAGEALIGN_ALLOC],
 [
-  AC_REQUIRE([gl_FUNC_MMAP])
+  AC_REQUIRE([gl_FUNC_MMAP_ANON])
   AC_REQUIRE([gl_GETPAGESIZE])
   AC_CHECK_FUNCS_ONCE([posix_memalign])
   AC_CHECK_HEADERS_ONCE([fcntl.h unistd.h])

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]