diff src/lisp.h @ 5179:14fda1dbdb26

add memory usage info for specifiers -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-29 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (lisp_object_storage_size): * alloc.c (Fobject_memory_usage): * alloc.c (lisp_object_memory_usage_full): Don't crash if passed a non-record object (int or char). * alloc.c (tree_memory_usage_1): * lrecord.h: New function tree_memory_usage() to return the memory usage of a tree of conses and/or vectors. * lisp.h: * lisp.h (PRIVATE_UNVERIFIED_LIST_LOOP_7): Add SAFE_LIST_LOOP_* functions for looping over a list not known to be correct or non-circular, but without signalling an error -- instead, just stop enumerating when an error detected. * emacs.c (main_1): * specifier.c: * specifier.c (specifier_memory_usage): * specifier.c (vars_of_specifier): * symsinit.h: Add memory usage info for specifiers.
author Ben Wing <ben@xemacs.org>
date Mon, 29 Mar 2010 22:47:55 -0500
parents 5ddbab03b0e6
children 4cd28c29a7a1
line wrap: on
line diff
--- a/src/lisp.h	Mon Mar 29 00:11:03 2010 -0500
+++ b/src/lisp.h	Mon Mar 29 22:47:55 2010 -0500
@@ -2119,21 +2119,46 @@
 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail,			\
 		      tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
 
-
-#define PRIVATE_EXTERNAL_LIST_LOOP_6(elt, list, len, hare,		\
-				     tortoise, suspicion_length)	\
+#define PRIVATE_UNVERIFIED_LIST_LOOP_7(elt, list, len, hare,		\
+				       tortoise, suspicion_length,	\
+                                       signalp)				\
   for (tortoise = hare = list, len = 0;					\
 									\
        (CONSP (hare) ? ((elt = XCAR (hare)), 1) :			\
 	(NILP (hare) ? 0 :						\
-	 (signal_malformed_list_error (list), 0)));			\
+	 ((signalp ? signal_malformed_list_error (list) : 0), 0)));	\
 									\
        hare = XCDR (hare),						\
 	 (void)								\
 	 ((++len > suspicion_length)					\
 	  &&								\
 	  ((((len & 1) != 0) && (tortoise = XCDR (tortoise), 0)),	\
-	   (EQ (hare, tortoise) && (signal_circular_list_error (list), 0)))))
+	   (EQ (hare, tortoise) &&					\
+            ((signalp ? signal_circular_list_error (list) : 0), 0)))))
+
+#define PRIVATE_EXTERNAL_LIST_LOOP_6(elt, list, len, hare,		\
+				     tortoise, suspicion_length)	\
+  PRIVATE_UNVERIFIED_LIST_LOOP_7 (elt, list, len, hare, tortoise,	\
+                                  suspicion_length, 1)
+
+#define PRIVATE_SAFE_LIST_LOOP_6(elt, list, len, hare,			\
+				 tortoise, suspicion_length)		\
+  PRIVATE_UNVERIFIED_LIST_LOOP_7 (elt, list, len, hare, tortoise,	\
+                                  suspicion_length, 0)
+
+/* Similar to EXTERNAL_LIST_LOOP_2() but don't signal when an error
+   is detected, just stop. */
+#define SAFE_LIST_LOOP_2(elt, list)					\
+Lisp_Object elt, hare_##elt, tortoise_##elt;				\
+EMACS_INT len_##elt;							\
+PRIVATE_SAFE_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt,		\
+		          tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define SAFE_LIST_LOOP_3(elt, list, tail)				\
+Lisp_Object elt, tail, tortoise_##elt;					\
+EMACS_INT len_##elt;							\
+PRIVATE_SAFE_LIST_LOOP_6 (elt, list, len_##elt, tail,			\
+		          tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
 
 /* GET_LIST_LENGTH and GET_EXTERNAL_LIST_LENGTH: