/[emacs]/emacs/src/alloc.c
ViewVC logotype

Diff of /emacs/src/alloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.285 by schwab, Fri Jan 10 20:08:32 2003 UTC revision 1.286 by kfstorm, Sun Jan 12 00:40:09 2003 UTC
# Line 3833  pure_alloc (size, type) Line 3833  pure_alloc (size, type)
3833  {  {
3834    size_t nbytes;    size_t nbytes;
3835    POINTER_TYPE *result;    POINTER_TYPE *result;
3836    char *beg = purebeg;    char *beg;
3837    
3838     again:
3839      beg = purebeg;
3840      result = (POINTER_TYPE *) (beg + pure_bytes_used);
3841      nbytes = ALIGN (size, sizeof (EMACS_INT));
3842    
3843    /* Give Lisp_Floats an extra alignment.  */    /* Give Lisp_Floats an extra alignment.  */
3844    if (type == Lisp_Float)    if (type == Lisp_Float)
3845      {      {
3846          POINTER_TYPE *orig = result;
3847        size_t alignment;        size_t alignment;
3848  #if defined __GNUC__ && __GNUC__ >= 2  #if defined __GNUC__ && __GNUC__ >= 2
3849        alignment = __alignof (struct Lisp_Float);        alignment = __alignof (struct Lisp_Float);
3850  #else  #else
3851        alignment = sizeof (struct Lisp_Float);        alignment = sizeof (struct Lisp_Float);
3852  #endif  #endif
3853        /* Make sure beg + pure_bytes_used is correctly aligned for a        /* Make sure result is correctly aligned for a
3854           Lisp_Float, which might need stricter alignment than           Lisp_Float, which might need stricter alignment than
3855           EMACS_INT.  */           EMACS_INT.  */
3856        pure_bytes_used        result = (POINTER_TYPE *)ALIGN((EMACS_UINT)result, alignment);
3857          = (ALIGN ((EMACS_UINT) (beg + pure_bytes_used), alignment)        nbytes += (char *)result - (char *)orig;
            - (EMACS_UINT) beg);  
3858      }      }
3859            
   nbytes = ALIGN (size, sizeof (EMACS_INT));  
     
3860    if (pure_bytes_used + nbytes > pure_size)    if (pure_bytes_used + nbytes > pure_size)
3861      {      {
3862        /* Don't allocate a large amount here,        /* Don't allocate a large amount here,
3863           because it might get mmap'd and then its address           because it might get mmap'd and then its address
3864           might not be usable.  */           might not be usable.  */
3865        beg = purebeg = (char *) xmalloc (10000);        purebeg = (char *) xmalloc (10000);
3866        pure_size = 10000;        pure_size = 10000;
3867        pure_bytes_used_before_overflow += pure_bytes_used;        pure_bytes_used_before_overflow += pure_bytes_used;
3868        pure_bytes_used = 0;        pure_bytes_used = 0;
3869          goto again;
3870      }      }
3871    
   result = (POINTER_TYPE *) (beg + pure_bytes_used);  
3872    pure_bytes_used += nbytes;    pure_bytes_used += nbytes;
3873    return result;    return result;
3874  }  }

Legend:
Removed from v.1.285  
changed lines
  Added in v.1.286

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26