aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKim F. Storm2003-01-12 15:40:23 +0000
committerKim F. Storm2003-01-12 15:40:23 +0000
commit441174202f21deff8366a8060b9e4eed4e7c29aa (patch)
treeb9231ed78c7ae5293b54b8eac91dfd74524a9dc2 /src/alloc.c
parent035261dcccb2f8e1b88ec9074d2f714d993ba24c (diff)
downloademacs-441174202f21deff8366a8060b9e4eed4e7c29aa.tar.gz
emacs-441174202f21deff8366a8060b9e4eed4e7c29aa.zip
(pure_alloc): Rewritten and simplified.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f19c2328899..281288e69db 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3831,46 +3831,34 @@ pure_alloc (size, type)
3831 size_t size; 3831 size_t size;
3832 int type; 3832 int type;
3833{ 3833{
3834 size_t nbytes;
3835 POINTER_TYPE *result; 3834 POINTER_TYPE *result;
3836 char *beg; 3835 size_t alignment = sizeof (EMACS_INT);
3837
3838 again:
3839 beg = purebeg;
3840 result = (POINTER_TYPE *) (beg + pure_bytes_used);
3841 nbytes = ALIGN (size, sizeof (EMACS_INT));
3842 3836
3843 /* Give Lisp_Floats an extra alignment. */ 3837 /* Give Lisp_Floats an extra alignment. */
3844 if (type == Lisp_Float) 3838 if (type == Lisp_Float)
3845 { 3839 {
3846 POINTER_TYPE *orig = result;
3847 size_t alignment;
3848#if defined __GNUC__ && __GNUC__ >= 2 3840#if defined __GNUC__ && __GNUC__ >= 2
3849 alignment = __alignof (struct Lisp_Float); 3841 alignment = __alignof (struct Lisp_Float);
3850#else 3842#else
3851 alignment = sizeof (struct Lisp_Float); 3843 alignment = sizeof (struct Lisp_Float);
3852#endif 3844#endif
3853 /* Make sure result is correctly aligned for a
3854 Lisp_Float, which might need stricter alignment than
3855 EMACS_INT. */
3856 result = (POINTER_TYPE *)ALIGN((EMACS_UINT)result, alignment);
3857 nbytes += (char *)result - (char *)orig;
3858 }
3859
3860 if (pure_bytes_used + nbytes > pure_size)
3861 {
3862 /* Don't allocate a large amount here,
3863 because it might get mmap'd and then its address
3864 might not be usable. */
3865 purebeg = (char *) xmalloc (10000);
3866 pure_size = 10000;
3867 pure_bytes_used_before_overflow += pure_bytes_used;
3868 pure_bytes_used = 0;
3869 goto again;
3870 } 3845 }
3871 3846
3872 pure_bytes_used += nbytes; 3847 again:
3873 return result; 3848 result = (POINTER_TYPE *) ALIGN ((EMACS_UINT)purebeg + pure_bytes_used, alignment);
3849 pure_bytes_used = ((char *)result - (char *)purebeg) + size;
3850
3851 if (pure_bytes_used <= pure_size)
3852 return result;
3853
3854 /* Don't allocate a large amount here,
3855 because it might get mmap'd and then its address
3856 might not be usable. */
3857 purebeg = (char *) xmalloc (10000);
3858 pure_size = 10000;
3859 pure_bytes_used_before_overflow += pure_bytes_used - size;
3860 pure_bytes_used = 0;
3861 goto again;
3874} 3862}
3875 3863
3876 3864