# HG changeset patch # User Gerd Moellmann # Date 1061297886 0 # Node ID 36e112575ca8d376a603ae74633cc400c0b6bb90 # Parent eb8d63124c39bf865cb09b50ff537544d6fd73b3 (lisp_align_malloc): Check for memory full when allocating ablocks, which also avoids freeing a pointer into an ablocks structure. diff -r eb8d63124c39 -r 36e112575ca8 src/alloc.c --- a/src/alloc.c Tue Aug 19 12:42:32 2003 +0000 +++ b/src/alloc.c Tue Aug 19 12:58:06 2003 +0000 @@ -766,6 +766,23 @@ mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); #endif + /* If the memory just allocated cannot be addressed thru a Lisp + object's pointer, and it needs to be, that's equivalent to + running out of memory. */ + if (type != MEM_TYPE_NON_LISP) + { + Lisp_Object tem; + char *end = (char *) base + ABLOCKS_BYTES - 1; + XSETCONS (tem, end); + if ((char *) XCONS (tem) != end) + { + lisp_malloc_loser = base; + free (base); + UNBLOCK_INPUT; + memory_full (); + } + } + /* Initialize the blocks and put them on the free list. Is `base' was not properly aligned, we can't use the last block. */ for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) @@ -788,21 +805,6 @@ val = free_ablock; free_ablock = free_ablock->x.next_free; - /* If the memory just allocated cannot be addressed thru a Lisp - object's pointer, and it needs to be, - that's equivalent to running out of memory. */ - if (val && type != MEM_TYPE_NON_LISP) - { - Lisp_Object tem; - XSETCONS (tem, (char *) val + nbytes - 1); - if ((char *) XCONS (tem) != (char *) val + nbytes - 1) - { - lisp_malloc_loser = val; - free (val); - val = 0; - } - } - #if GC_MARK_STACK && !defined GC_MALLOC_CHECK if (val && type != MEM_TYPE_NON_LISP) mem_insert (val, (char *) val + nbytes, type);