aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-03-30 09:29:22 +0000
committerGerd Moellmann2000-03-30 09:29:22 +0000
commitdca7c6a8d2abaef803a38d1efe40cda8b7eff2a5 (patch)
tree459521ffb36ace18142f3d9e6a2e14129a12de52
parente3130015d6f811729b8d3c883c586ff74f0636ec (diff)
downloademacs-dca7c6a8d2abaef803a38d1efe40cda8b7eff2a5.tar.gz
emacs-dca7c6a8d2abaef803a38d1efe40cda8b7eff2a5.zip
(xstrdup): Moved here from xfaces.c.
(allocating_for_lisp): Variable removed. (lisp_malloc): Block input around the calls to malloc and mem_insert.
-rw-r--r--src/alloc.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 3b5d0e57ace..a32718d82f4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -170,11 +170,6 @@ static char *spare_memory;
170 170
171static int malloc_hysteresis; 171static int malloc_hysteresis;
172 172
173/* Nonzero when malloc is called for allocating Lisp object space.
174 Currently set but not used. */
175
176int allocating_for_lisp;
177
178/* Non-nil means defun should do purecopy on the function definition. */ 173/* Non-nil means defun should do purecopy on the function definition. */
179 174
180Lisp_Object Vpurify_flag; 175Lisp_Object Vpurify_flag;
@@ -464,6 +459,19 @@ xfree (block)
464} 459}
465 460
466 461
462/* Like strdup, but uses xmalloc. */
463
464char *
465xstrdup (s)
466 char *s;
467{
468 int len = strlen (s) + 1;
469 char *p = (char *) xmalloc (len);
470 bcopy (s, p, len);
471 return p;
472}
473
474
467/* Like malloc but used for allocating Lisp data. NBYTES is the 475/* Like malloc but used for allocating Lisp data. NBYTES is the
468 number of bytes to allocate, TYPE describes the intended use of the 476 number of bytes to allocate, TYPE describes the intended use of the
469 allcated memory block (for strings, for conses, ...). */ 477 allcated memory block (for strings, for conses, ...). */
@@ -476,19 +484,16 @@ lisp_malloc (nbytes, type)
476 register void *val; 484 register void *val;
477 485
478 BLOCK_INPUT; 486 BLOCK_INPUT;
479 allocating_for_lisp++;
480 val = (void *) malloc (nbytes); 487 val = (void *) malloc (nbytes);
481 allocating_for_lisp--;
482 UNBLOCK_INPUT;
483 488
484 if (!val && nbytes)
485 memory_full ();
486
487#if GC_MARK_STACK 489#if GC_MARK_STACK
488 if (type != MEM_TYPE_NON_LISP) 490 if (val && type != MEM_TYPE_NON_LISP)
489 mem_insert (val, (char *) val + nbytes, type); 491 mem_insert (val, (char *) val + nbytes, type);
490#endif 492#endif
491 493
494 UNBLOCK_INPUT;
495 if (!val && nbytes)
496 memory_full ();
492 return val; 497 return val;
493} 498}
494 499
@@ -512,12 +517,10 @@ lisp_free (block)
512 long *block; 517 long *block;
513{ 518{
514 BLOCK_INPUT; 519 BLOCK_INPUT;
515 allocating_for_lisp++;
516 free (block); 520 free (block);
517#if GC_MARK_STACK 521#if GC_MARK_STACK
518 mem_delete (mem_find (block)); 522 mem_delete (mem_find (block));
519#endif 523#endif
520 allocating_for_lisp--;
521 UNBLOCK_INPUT; 524 UNBLOCK_INPUT;
522} 525}
523 526