Re: valloc()?
Derek Price <[email protected]> Thu, 03 Mar 2005 10:26:02 -0500
| Newsgroups | gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs |
|---|---|
| Organization | Get CVS Support from Ximbiot <http://ximbiot.com>! |
| Message-ID | <[email protected]> |
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 <[email protected]>
* 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
_______________________________________________
bug-gnulib mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnulib
pagealign_alloc-nits.diff
(text/plain, 2.5 KB)
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])
signature.asc
(application/pgp-signature, 253 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCJyyKLD1OTBfyMaQRArKFAJ9Ww7yZvyEbmp4SFfoPNc+3j8mlzgCfZ+2C Zj9ruZLtVMJBasD91K+PnJc= =WHEZ -----END PGP SIGNATURE-----