comparison src/alloc.c @ 420:41dbb7a9d5f2 r21-2-18

Import from CVS: tag r21-2-18
author cvs
date Mon, 13 Aug 2007 11:24:09 +0200
parents da8ed4261e83
children 11054d720c21
comparison
equal deleted inserted replaced
419:66615b78f1a5 420:41dbb7a9d5f2
55 #include "opaque.h" 55 #include "opaque.h"
56 #include "redisplay.h" 56 #include "redisplay.h"
57 #include "specifier.h" 57 #include "specifier.h"
58 #include "sysfile.h" 58 #include "sysfile.h"
59 #include "window.h" 59 #include "window.h"
60
61 #include <stddef.h>
62 60
63 #ifdef DOUG_LEA_MALLOC 61 #ifdef DOUG_LEA_MALLOC
64 #include <malloc.h> 62 #include <malloc.h>
65 #endif 63 #endif
66 64
965 return internal_equal (ob1, ob2, depth + 1); 963 return internal_equal (ob1, ob2, depth + 1);
966 } 964 }
967 return 0; 965 return 0;
968 } 966 }
969 967
968 static const struct lrecord_description cons_description[] = {
969 { XD_LISP_OBJECT, offsetof(struct Lisp_Cons, car), 2 },
970 { XD_END }
971 };
972
970 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("cons", cons, 973 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("cons", cons,
971 mark_cons, print_cons, 0, 974 mark_cons, print_cons, 0,
972 cons_equal, 975 cons_equal,
973 /* 976 /*
974 * No `hash' method needed. 977 * No `hash' method needed.
975 * internal_hash knows how to 978 * internal_hash knows how to
976 * handle conses. 979 * handle conses.
977 */ 980 */
978 0, 981 0,
982 cons_description,
979 struct Lisp_Cons); 983 struct Lisp_Cons);
980 984
981 DEFUN ("cons", Fcons, 2, 2, 0, /* 985 DEFUN ("cons", Fcons, 2, 2, 0, /*
982 Create a new cons, give it CAR and CDR as components, and return it. 986 Create a new cons, give it CAR and CDR as components, and return it.
983 */ 987 */
1163 if (!internal_equal (*ptr1++, *ptr2++, depth + 1)) 1167 if (!internal_equal (*ptr1++, *ptr2++, depth + 1))
1164 return 0; 1168 return 0;
1165 } 1169 }
1166 return 1; 1170 return 1;
1167 } 1171 }
1172
1173 static const struct lrecord_description vector_description[] = {
1174 { XD_LONG, offsetof(struct Lisp_Vector, size) },
1175 { XD_LISP_OBJECT, offsetof(struct Lisp_Vector, contents), XD_INDIRECT(0) }
1176 };
1168 1177
1169 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION("vector", vector, 1178 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION("vector", vector,
1170 mark_vector, print_vector, 0, 1179 mark_vector, print_vector, 0,
1171 vector_equal, 1180 vector_equal,
1172 /* 1181 /*
1173 * No `hash' method needed for 1182 * No `hash' method needed for
1174 * vectors. internal_hash 1183 * vectors. internal_hash
1175 * knows how to handle vectors. 1184 * knows how to handle vectors.
1176 */ 1185 */
1177 0, 1186 0,
1187 vector_description,
1178 size_vector, Lisp_Vector); 1188 size_vector, Lisp_Vector);
1179 1189
1180 /* #### should allocate `small' vectors from a frob-block */ 1190 /* #### should allocate `small' vectors from a frob-block */
1181 static Lisp_Vector * 1191 static Lisp_Vector *
1182 make_vector_internal (size_t sizei) 1192 make_vector_internal (size_t sizei)
1741 Bytecount len; 1751 Bytecount len;
1742 return (((len = XSTRING_LENGTH (obj1)) == XSTRING_LENGTH (obj2)) && 1752 return (((len = XSTRING_LENGTH (obj1)) == XSTRING_LENGTH (obj2)) &&
1743 !memcmp (XSTRING_DATA (obj1), XSTRING_DATA (obj2), len)); 1753 !memcmp (XSTRING_DATA (obj1), XSTRING_DATA (obj2), len));
1744 } 1754 }
1745 1755
1756 static const struct lrecord_description string_description[] = {
1757 { XD_STRING_DATA, offsetof(Lisp_String, data) },
1758 { XD_LISP_OBJECT, offsetof(Lisp_String, plist), 1 },
1759 { XD_END }
1760 };
1761
1746 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("string", string, 1762 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("string", string,
1747 mark_string, print_string, 1763 mark_string, print_string,
1748 /* 1764 /*
1749 * No `finalize', or `hash' methods. 1765 * No `finalize', or `hash' methods.
1750 * internal_hash already knows how 1766 * internal_hash already knows how
1754 * which is the standard way to do 1770 * which is the standard way to do
1755 * finalization when using 1771 * finalization when using
1756 * SWEEP_FIXED_TYPE_BLOCK(). 1772 * SWEEP_FIXED_TYPE_BLOCK().
1757 */ 1773 */
1758 0, string_equal, 0, 1774 0, string_equal, 0,
1775 string_description,
1759 struct Lisp_String); 1776 struct Lisp_String);
1760 1777
1761 /* String blocks contain this many useful bytes. */ 1778 /* String blocks contain this many useful bytes. */
1762 #define STRING_CHARS_BLOCK_SIZE \ 1779 #define STRING_CHARS_BLOCK_SIZE \
1763 ((Bytecount) (8192 - MALLOC_OVERHEAD - \ 1780 ((Bytecount) (8192 - MALLOC_OVERHEAD - \
2241 return Qnil; 2258 return Qnil;
2242 } 2259 }
2243 2260
2244 DEFINE_LRECORD_IMPLEMENTATION ("lcrecord-list", lcrecord_list, 2261 DEFINE_LRECORD_IMPLEMENTATION ("lcrecord-list", lcrecord_list,
2245 mark_lcrecord_list, internal_object_printer, 2262 mark_lcrecord_list, internal_object_printer,
2246 0, 0, 0, struct lcrecord_list); 2263 0, 0, 0, 0, struct lcrecord_list);
2247 Lisp_Object 2264 Lisp_Object
2248 make_lcrecord_list (size_t size, 2265 make_lcrecord_list (size_t size,
2249 CONST struct lrecord_implementation *implementation) 2266 CONST struct lrecord_implementation *implementation)
2250 { 2267 {
2251 struct lcrecord_list *p = alloc_lcrecord_type (struct lcrecord_list, 2268 struct lcrecord_list *p = alloc_lcrecord_type (struct lcrecord_list,