aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKim F. Storm2005-11-09 23:14:12 +0000
committerKim F. Storm2005-11-09 23:14:12 +0000
commit3cd557353770ab49a9068d6c7f9d3523cab0e17c (patch)
treecc9dcee2095de0e7c7d0a91b216aa76e45d540c3 /src/alloc.c
parent1609a9633f98795e6f5feb69a6a9b37dfac5d2b0 (diff)
downloademacs-3cd557353770ab49a9068d6c7f9d3523cab0e17c.tar.gz
emacs-3cd557353770ab49a9068d6c7f9d3523cab0e17c.zip
(valid_lisp_object_p): New function to validate that
an object is really a valid Lisp_Object.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ab3ca918b30..d006b6e3f01 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4484,10 +4484,79 @@ mark_stack ()
4484#endif 4484#endif
4485} 4485}
4486 4486
4487
4488#endif /* GC_MARK_STACK != 0 */ 4487#endif /* GC_MARK_STACK != 0 */
4489 4488
4490 4489
4490
4491/* Return 1 if OBJ is a valid lisp object.
4492 Return 0 if OBJ is NOT a valid lisp object.
4493 Return -1 if we cannot validate OBJ.
4494*/
4495
4496int
4497valid_lisp_object_p (obj)
4498 Lisp_Object obj;
4499{
4500#if !GC_MARK_STACK
4501 /* Cannot determine this. */
4502 return -1;
4503#else
4504 void *p;
4505 struct mem_node *m;
4506
4507 if (INTEGERP (obj))
4508 return 1;
4509
4510 p = (void *) XPNTR (obj);
4511
4512 if (PURE_POINTER_P (p))
4513 return 1;
4514
4515 m = mem_find (p);
4516
4517 if (m == MEM_NIL)
4518 return 0;
4519
4520 switch (m->type)
4521 {
4522 case MEM_TYPE_NON_LISP:
4523 return 0;
4524
4525 case MEM_TYPE_BUFFER:
4526 return live_buffer_p (m, p);
4527
4528 case MEM_TYPE_CONS:
4529 return live_cons_p (m, p);
4530
4531 case MEM_TYPE_STRING:
4532 return live_string_p (m, p);
4533
4534 case MEM_TYPE_MISC:
4535 return live_misc_p (m, p);
4536
4537 case MEM_TYPE_SYMBOL:
4538 return live_symbol_p (m, p);
4539
4540 case MEM_TYPE_FLOAT:
4541 return live_float_p (m, p);
4542
4543 case MEM_TYPE_VECTOR:
4544 case MEM_TYPE_PROCESS:
4545 case MEM_TYPE_HASH_TABLE:
4546 case MEM_TYPE_FRAME:
4547 case MEM_TYPE_WINDOW:
4548 return live_vector_p (m, p);
4549
4550 default:
4551 break;
4552 }
4553
4554 return 0;
4555#endif
4556}
4557
4558
4559
4491 4560
4492/*********************************************************************** 4561/***********************************************************************
4493 Pure Storage Management 4562 Pure Storage Management
@@ -4967,7 +5036,7 @@ returns nil, because real GC can't be done. */)
4967 total += total_floats * sizeof (struct Lisp_Float); 5036 total += total_floats * sizeof (struct Lisp_Float);
4968 total += total_intervals * sizeof (struct interval); 5037 total += total_intervals * sizeof (struct interval);
4969 total += total_strings * sizeof (struct Lisp_String); 5038 total += total_strings * sizeof (struct Lisp_String);
4970 5039
4971 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage); 5040 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
4972 } 5041 }
4973 else 5042 else