[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/alloc.c,v
From: |
Kim F. Storm |
Subject: |
[Emacs-diffs] Changes to emacs/src/alloc.c,v |
Date: |
Fri, 28 Jul 2006 11:12:23 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Kim F. Storm <kfstorm> 06/07/28 11:12:23
Index: alloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/alloc.c,v
retrieving revision 1.398
retrieving revision 1.399
diff -u -b -r1.398 -r1.399
--- alloc.c 25 Jul 2006 10:10:19 -0000 1.398
+++ alloc.c 28 Jul 2006 11:12:23 -0000 1.399
@@ -4606,6 +4606,27 @@
#endif /* GC_MARK_STACK != 0 */
+/* Determine whether it is safe to access memory at address P. */
+int valid_pointer_p (p)
+ void *p;
+{
+ int fd;
+
+ /* Obviously, we cannot just access it (we would SEGV trying), so we
+ trick the o/s to tell us whether p is a valid pointer.
+ Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
+ not validate p in that case. */
+
+ if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY |
O_TRUNC, 0666)) >= 0)
+ {
+ int valid = (emacs_write (fd, (char *)p, 16) == 16);
+ emacs_close (fd);
+ unlink ("__Valid__Lisp__Object__");
+ return valid;
+ }
+
+ return -1;
+}
/* Return 1 if OBJ is a valid lisp object.
Return 0 if OBJ is NOT a valid lisp object.
@@ -4618,9 +4639,7 @@
Lisp_Object obj;
{
void *p;
-#if !GC_MARK_STACK
- int fd;
-#else
+#if GC_MARK_STACK
struct mem_node *m;
#endif
@@ -4632,26 +4651,22 @@
return 1;
#if !GC_MARK_STACK
- /* We need to determine whether it is safe to access memory at
- address P. Obviously, we cannot just access it (we would SEGV
- trying), so we trick the o/s to tell us whether p is a valid
- pointer. Unfortunately, we cannot use NULL_DEVICE here, as
- emacs_write may not validate p in that case. */
- if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY |
O_TRUNC, 0666)) >= 0)
- {
- int valid = (emacs_write (fd, (char *)p, 16) == 16);
- emacs_close (fd);
- unlink ("__Valid__Lisp__Object__");
- return valid;
- }
-
- return -1;
+ return valid_pointer_p (p);
#else
m = mem_find (p);
if (m == MEM_NIL)
+ {
+ int valid = valid_pointer_p (p);
+ if (valid <= 0)
+ return valid;
+
+ if (SUBRP (obj))
+ return 1;
+
return 0;
+ }
switch (m->type)
{
- [Emacs-diffs] Changes to emacs/src/alloc.c,v, Kim F. Storm, 2006/07/18
- [Emacs-diffs] Changes to emacs/src/alloc.c,v, YAMAMOTO Mitsuharu, 2006/07/19
- [Emacs-diffs] Changes to emacs/src/alloc.c,v, YAMAMOTO Mitsuharu, 2006/07/25
- [Emacs-diffs] Changes to emacs/src/alloc.c,v,
Kim F. Storm <=
- [Emacs-diffs] Changes to emacs/src/alloc.c,v, Richard M. Stallman, 2006/07/28
- [Emacs-diffs] Changes to emacs/src/alloc.c,v, Eli Zaretskii, 2006/07/29