Mercurial > hg > octave-lyh > gnulib-hg
changeset 5683:d0a22d17762b
Set errno when malloc() fails.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 04 Mar 2005 12:28:13 +0000 |
parents | f8c8874bd832 |
children | 0aebab2c04d4 |
files | lib/pagealign_alloc.c |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/pagealign_alloc.c +++ b/lib/pagealign_alloc.c @@ -149,7 +149,12 @@ size_t pagesize = getpagesize (); void *unaligned_ptr = malloc (size + pagesize - 1); if (unaligned_ptr == NULL) - return NULL; + { + /* Set errno. We don't know whether malloc already set errno: some + implementations of malloc do, some don't. */ + errno = ENOMEM; + return NULL; + } ret = (char *) unaligned_ptr + ((- (unsigned long) unaligned_ptr) & (pagesize - 1)); new_memnode (ret, unaligned_ptr);