comparison src/alloc.c @ 382:064ab7fed2e0 r21-2-6

Import from CVS: tag r21-2-6
author cvs
date Mon, 13 Aug 2007 11:07:39 +0200
parents 8626e4521993
children 4af0ddfb7c5b
comparison
equal deleted inserted replaced
381:908a86f940e6 382:064ab7fed2e0
63 #include <malloc.h> 63 #include <malloc.h>
64 #endif 64 #endif
65 65
66 EXFUN (Fgarbage_collect, 0); 66 EXFUN (Fgarbage_collect, 0);
67 67
68 /* #define GDB_SUCKS */ 68 /* Return the true size of a struct with a variable-length array field. */
69 #define STRETCHY_STRUCT_SIZEOF(stretchy_struct_type, \
70 stretchy_array_field, \
71 stretchy_array_length) \
72 (offsetof (stretchy_struct_type, stretchy_array_field) + \
73 (offsetof (stretchy_struct_type, stretchy_array_field[1]) - \
74 offsetof (stretchy_struct_type, stretchy_array_field[0])) * \
75 (stretchy_array_length))
69 76
70 #if 0 /* this is _way_ too slow to be part of the standard debug options */ 77 #if 0 /* this is _way_ too slow to be part of the standard debug options */
71 #if defined(DEBUG_XEMACS) && defined(MULE) 78 #if defined(DEBUG_XEMACS) && defined(MULE)
72 #define VERIFY_STRING_CHARS_INTEGRITY 79 #define VERIFY_STRING_CHARS_INTEGRITY
73 #endif 80 #endif
1301 } 1308 }
1302 1309
1303 static size_t 1310 static size_t
1304 size_vector (CONST void *lheader) 1311 size_vector (CONST void *lheader)
1305 { 1312 {
1306 return offsetof (Lisp_Vector, contents[((Lisp_Vector *) lheader)->size]); 1313 return STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents,
1314 ((Lisp_Vector *) lheader)->size);
1307 } 1315 }
1308 1316
1309 static int 1317 static int
1310 vector_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 1318 vector_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
1311 { 1319 {
1312 int indice;
1313 int len = XVECTOR_LENGTH (obj1); 1320 int len = XVECTOR_LENGTH (obj1);
1314 if (len != XVECTOR_LENGTH (obj2)) 1321 if (len != XVECTOR_LENGTH (obj2))
1315 return 0; 1322 return 0;
1316 for (indice = 0; indice < len; indice++) 1323
1317 { 1324 {
1318 if (!internal_equal (XVECTOR_DATA (obj1) [indice], 1325 Lisp_Object *ptr1 = XVECTOR_DATA (obj1);
1319 XVECTOR_DATA (obj2) [indice], 1326 Lisp_Object *ptr2 = XVECTOR_DATA (obj2);
1320 depth + 1)) 1327 while (len--)
1328 if (!internal_equal (*ptr1++, *ptr2++, depth + 1))
1321 return 0; 1329 return 0;
1322 } 1330 }
1323 return 1; 1331 return 1;
1324 } 1332 }
1325 1333
1326 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION("vector", vector, 1334 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION("vector", vector,
1327 mark_vector, print_vector, 0, 1335 mark_vector, print_vector, 0,
1337 /* #### should allocate `small' vectors from a frob-block */ 1345 /* #### should allocate `small' vectors from a frob-block */
1338 static Lisp_Vector * 1346 static Lisp_Vector *
1339 make_vector_internal (size_t sizei) 1347 make_vector_internal (size_t sizei)
1340 { 1348 {
1341 /* no vector_next */ 1349 /* no vector_next */
1342 size_t sizem = offsetof (Lisp_Vector, contents[sizei]); 1350 size_t sizem = STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents, sizei);
1343 Lisp_Vector *p = (Lisp_Vector *) alloc_lcrecord (sizem, lrecord_vector); 1351 Lisp_Vector *p = (Lisp_Vector *) alloc_lcrecord (sizem, lrecord_vector);
1344 1352
1345 p->size = sizei; 1353 p->size = sizei;
1346 return p; 1354 return p;
1347 } 1355 }
1353 /* #### should allocate `small' vectors from a frob-block */ 1361 /* #### should allocate `small' vectors from a frob-block */
1354 static Lisp_Vector * 1362 static Lisp_Vector *
1355 make_vector_internal (size_t sizei) 1363 make_vector_internal (size_t sizei)
1356 { 1364 {
1357 /* + 1 to account for vector_next */ 1365 /* + 1 to account for vector_next */
1358 size_t sizem = offsetof (Lisp_Vector, contents[sizei+1]); 1366 size_t sizem = STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents, sizei+1);
1359 Lisp_Vector *p = (Lisp_Vector *) allocate_lisp_storage (sizem); 1367 Lisp_Vector *p = (Lisp_Vector *) allocate_lisp_storage (sizem);
1360 1368
1361 INCREMENT_CONS_COUNTER (sizem, "vector"); 1369 INCREMENT_CONS_COUNTER (sizem, "vector");
1362 1370
1363 p->size = sizei; 1371 p->size = sizei;
1367 } 1375 }
1368 1376
1369 #endif /* ! LRECORD_VECTOR */ 1377 #endif /* ! LRECORD_VECTOR */
1370 1378
1371 Lisp_Object 1379 Lisp_Object
1372 make_vector (EMACS_INT length, Lisp_Object init) 1380 make_vector (size_t length, Lisp_Object init)
1373 { 1381 {
1374 int elt; 1382 Lisp_Vector *vecp = make_vector_internal (length);
1375 Lisp_Object vector; 1383 Lisp_Object *p = vector_data (vecp);
1376 Lisp_Vector *p; 1384
1377 1385 while (length--)
1378 if (length < 0) 1386 *p++ = init;
1379 length = XINT (wrong_type_argument (Qnatnump, make_int (length))); 1387
1380
1381 p = make_vector_internal (length);
1382 XSETVECTOR (vector, p);
1383
1384 #if 0
1385 /* Initialize big arrays full of 0's quickly, for what that's worth */
1386 { 1388 {
1387 char *travesty = (char *) &init; 1389 Lisp_Object vector;
1388 for (i = 1; i < sizeof (Lisp_Object); i++) 1390 XSETVECTOR (vector, vecp);
1389 {
1390 if (travesty[i] != travesty[0])
1391 goto fill;
1392 }
1393 memset (vector_data (p), travesty[0], length * sizeof (Lisp_Object));
1394 return vector; 1391 return vector;
1395 } 1392 }
1396 fill:
1397 #endif
1398 for (elt = 0; elt < length; elt++)
1399 vector_data(p)[elt] = init;
1400
1401 return vector;
1402 } 1393 }
1403 1394
1404 DEFUN ("make-vector", Fmake_vector, 2, 2, 0, /* 1395 DEFUN ("make-vector", Fmake_vector, 2, 2, 0, /*
1405 Return a new vector of length LENGTH, with each element being INIT. 1396 Return a new vector of length LENGTH, with each element being INIT.
1406 See also the function `vector'. 1397 See also the function `vector'.
1407 */ 1398 */
1408 (length, init)) 1399 (length, init))
1409 { 1400 {
1410 CHECK_NATNUM (length); 1401 CONCHECK_NATNUM (length);
1411 return make_vector (XINT (length), init); 1402 return make_vector (XINT (length), init);
1412 } 1403 }
1413 1404
1414 DEFUN ("vector", Fvector, 0, MANY, 0, /* 1405 DEFUN ("vector", Fvector, 0, MANY, 0, /*
1415 Return a newly created vector with specified arguments as elements. 1406 Return a newly created vector with specified arguments as elements.
1416 Any number of arguments, even zero arguments, are allowed. 1407 Any number of arguments, even zero arguments, are allowed.
1417 */ 1408 */
1418 (int nargs, Lisp_Object *args)) 1409 (int nargs, Lisp_Object *args))
1419 { 1410 {
1420 Lisp_Object vector; 1411 Lisp_Vector *vecp = make_vector_internal (nargs);
1421 int elt; 1412 Lisp_Object *p = vector_data (vecp);
1422 Lisp_Vector *p = make_vector_internal (nargs); 1413
1423 1414 while (nargs--)
1424 for (elt = 0; elt < nargs; elt++) 1415 *p++ = *args++;
1425 vector_data(p)[elt] = args[elt]; 1416
1426 1417 {
1427 XSETVECTOR (vector, p); 1418 Lisp_Object vector;
1428 return vector; 1419 XSETVECTOR (vector, vecp);
1420 return vector;
1421 }
1429 } 1422 }
1430 1423
1431 Lisp_Object 1424 Lisp_Object
1432 vector1 (Lisp_Object obj0) 1425 vector1 (Lisp_Object obj0)
1433 { 1426 {
1536 1529
1537 /* #### should allocate `small' bit vectors from a frob-block */ 1530 /* #### should allocate `small' bit vectors from a frob-block */
1538 static struct Lisp_Bit_Vector * 1531 static struct Lisp_Bit_Vector *
1539 make_bit_vector_internal (size_t sizei) 1532 make_bit_vector_internal (size_t sizei)
1540 { 1533 {
1541 size_t sizem = 1534 size_t num_longs = BIT_VECTOR_LONG_STORAGE (sizei);
1542 offsetof (Lisp_Bit_Vector, bits[BIT_VECTOR_LONG_STORAGE (sizei)]); 1535 size_t sizem = STRETCHY_STRUCT_SIZEOF (Lisp_Bit_Vector, bits, num_longs);
1543 Lisp_Bit_Vector *p = (Lisp_Bit_Vector *) allocate_lisp_storage (sizem); 1536 Lisp_Bit_Vector *p = (Lisp_Bit_Vector *) allocate_lisp_storage (sizem);
1544 set_lheader_implementation (&(p->lheader), lrecord_bit_vector); 1537 set_lheader_implementation (&(p->lheader), lrecord_bit_vector);
1545 1538
1546 INCREMENT_CONS_COUNTER (sizem, "bit-vector"); 1539 INCREMENT_CONS_COUNTER (sizem, "bit-vector");
1547 1540
1548 bit_vector_length (p) = sizei; 1541 bit_vector_length (p) = sizei;
1549 bit_vector_next (p) = all_bit_vectors; 1542 bit_vector_next (p) = all_bit_vectors;
1550 /* make sure the extra bits in the last long are 0; the calling 1543 /* make sure the extra bits in the last long are 0; the calling
1551 functions might not set them. */ 1544 functions might not set them. */
1552 p->bits[BIT_VECTOR_LONG_STORAGE (sizei) - 1] = 0; 1545 p->bits[num_longs - 1] = 0;
1553 XSETBIT_VECTOR (all_bit_vectors, p); 1546 XSETBIT_VECTOR (all_bit_vectors, p);
1554 return p; 1547 return p;
1555 } 1548 }
1556 1549
1557 Lisp_Object 1550 Lisp_Object
1558 make_bit_vector (EMACS_INT length, Lisp_Object init) 1551 make_bit_vector (size_t length, Lisp_Object init)
1559 { 1552 {
1560 Lisp_Object bit_vector; 1553 struct Lisp_Bit_Vector *p = make_bit_vector_internal (length);
1561 struct Lisp_Bit_Vector *p; 1554 size_t num_longs = BIT_VECTOR_LONG_STORAGE (length);
1562 EMACS_INT num_longs;
1563 1555
1564 CHECK_BIT (init); 1556 CHECK_BIT (init);
1565
1566 num_longs = BIT_VECTOR_LONG_STORAGE (length);
1567 p = make_bit_vector_internal (length);
1568 XSETBIT_VECTOR (bit_vector, p);
1569 1557
1570 if (ZEROP (init)) 1558 if (ZEROP (init))
1571 memset (p->bits, 0, num_longs * sizeof (long)); 1559 memset (p->bits, 0, num_longs * sizeof (long));
1572 else 1560 else
1573 { 1561 {
1574 EMACS_INT bits_in_last = length & (LONGBITS_POWER_OF_2 - 1); 1562 size_t bits_in_last = length & (LONGBITS_POWER_OF_2 - 1);
1575 memset (p->bits, ~0, num_longs * sizeof (long)); 1563 memset (p->bits, ~0, num_longs * sizeof (long));
1576 /* But we have to make sure that the unused bits in the 1564 /* But we have to make sure that the unused bits in the
1577 last integer are 0, so that equal/hash is easy. */ 1565 last long are 0, so that equal/hash is easy. */
1578 if (bits_in_last) 1566 if (bits_in_last)
1579 p->bits[num_longs - 1] &= (1 << bits_in_last) - 1; 1567 p->bits[num_longs - 1] &= (1 << bits_in_last) - 1;
1580 } 1568 }
1581 1569
1582 return bit_vector; 1570 {
1571 Lisp_Object bit_vector;
1572 XSETBIT_VECTOR (bit_vector, p);
1573 return bit_vector;
1574 }
1583 } 1575 }
1584 1576
1585 Lisp_Object 1577 Lisp_Object
1586 make_bit_vector_from_byte_vector (unsigned char *bytevec, EMACS_INT length) 1578 make_bit_vector_from_byte_vector (unsigned char *bytevec, size_t length)
1587 { 1579 {
1588 Lisp_Object bit_vector;
1589 struct Lisp_Bit_Vector *p;
1590 int i; 1580 int i;
1591 1581 Lisp_Bit_Vector *p = make_bit_vector_internal (length);
1592 if (length < 0)
1593 length = XINT (wrong_type_argument (Qnatnump, make_int (length)));
1594
1595 p = make_bit_vector_internal (length);
1596 XSETBIT_VECTOR (bit_vector, p);
1597 1582
1598 for (i = 0; i < length; i++) 1583 for (i = 0; i < length; i++)
1599 set_bit_vector_bit (p, i, bytevec[i]); 1584 set_bit_vector_bit (p, i, bytevec[i]);
1600 1585
1601 return bit_vector; 1586 {
1587 Lisp_Object bit_vector;
1588 XSETBIT_VECTOR (bit_vector, p);
1589 return bit_vector;
1590 }
1602 } 1591 }
1603 1592
1604 DEFUN ("make-bit-vector", Fmake_bit_vector, 2, 2, 0, /* 1593 DEFUN ("make-bit-vector", Fmake_bit_vector, 2, 2, 0, /*
1605 Return a new bit vector of length LENGTH. with each bit being INIT. 1594 Return a new bit vector of length LENGTH. with each bit being INIT.
1606 Each element is set to INIT. See also the function `bit-vector'. 1595 Each element is set to INIT. See also the function `bit-vector'.
1616 Return a newly created bit vector with specified arguments as elements. 1605 Return a newly created bit vector with specified arguments as elements.
1617 Any number of arguments, even zero arguments, are allowed. 1606 Any number of arguments, even zero arguments, are allowed.
1618 */ 1607 */
1619 (int nargs, Lisp_Object *args)) 1608 (int nargs, Lisp_Object *args))
1620 { 1609 {
1621 Lisp_Object bit_vector; 1610 int i;
1622 int elt; 1611 Lisp_Bit_Vector *p = make_bit_vector_internal (nargs);
1623 struct Lisp_Bit_Vector *p; 1612
1624 1613 for (i = 0; i < nargs; i++)
1625 for (elt = 0; elt < nargs; elt++) 1614 {
1626 CHECK_BIT (args[elt]); 1615 CHECK_BIT (args[i]);
1627 1616 set_bit_vector_bit (p, i, !ZEROP (args[i]));
1628 p = make_bit_vector_internal (nargs); 1617 }
1629 1618
1630 for (elt = 0; elt < nargs; elt++) 1619 {
1631 set_bit_vector_bit (p, elt, !ZEROP (args[elt])); 1620 Lisp_Object bit_vector;
1632 1621 XSETBIT_VECTOR (bit_vector, p);
1633 XSETBIT_VECTOR (bit_vector, p); 1622 return bit_vector;
1634 return bit_vector; 1623 }
1635 } 1624 }
1636 1625
1637 1626
1638 /************************************************************************/ 1627 /************************************************************************/
1639 /* Compiled-function allocation */ 1628 /* Compiled-function allocation */
2111 current_string_chars_block->pos += fullsize; 2100 current_string_chars_block->pos += fullsize;
2112 } 2101 }
2113 else 2102 else
2114 { 2103 {
2115 /* Make a new current string chars block */ 2104 /* Make a new current string chars block */
2116 struct string_chars_block *new = xnew (struct string_chars_block); 2105 struct string_chars_block *new_scb = xnew (struct string_chars_block);
2117 2106
2118 current_string_chars_block->next = new; 2107 current_string_chars_block->next = new_scb;
2119 new->prev = current_string_chars_block; 2108 new_scb->prev = current_string_chars_block;
2120 new->next = 0; 2109 new_scb->next = 0;
2121 current_string_chars_block = new; 2110 current_string_chars_block = new_scb;
2122 new->pos = fullsize; 2111 new_scb->pos = fullsize;
2123 s_chars = (struct string_chars *) 2112 s_chars = (struct string_chars *)
2124 current_string_chars_block->string_chars; 2113 current_string_chars_block->string_chars;
2125 } 2114 }
2126 2115
2127 s_chars->string = string_it_goes_with; 2116 s_chars->string = string_it_goes_with;
2305 #ifdef MULE 2294 #ifdef MULE
2306 2295
2307 void 2296 void
2308 set_string_char (struct Lisp_String *s, Charcount i, Emchar c) 2297 set_string_char (struct Lisp_String *s, Charcount i, Emchar c)
2309 { 2298 {
2310 Bytecount oldlen, newlen;
2311 Bufbyte newstr[MAX_EMCHAR_LEN]; 2299 Bufbyte newstr[MAX_EMCHAR_LEN];
2312 Bytecount bytoff = charcount_to_bytecount (string_data (s), i); 2300 Bytecount bytoff = charcount_to_bytecount (string_data (s), i);
2313 2301 Bytecount oldlen = charcount_to_bytecount (string_data (s) + bytoff, 1);
2314 oldlen = charcount_to_bytecount (string_data (s) + bytoff, 1); 2302 Bytecount newlen = set_charptr_emchar (newstr, c);
2315 newlen = set_charptr_emchar (newstr, c);
2316 2303
2317 if (oldlen != newlen) 2304 if (oldlen != newlen)
2318 resize_string (s, bytoff, newlen - oldlen); 2305 resize_string (s, bytoff, newlen - oldlen);
2319 /* Remember, string_data (s) might have changed so we can't cache it. */ 2306 /* Remember, string_data (s) might have changed so we can't cache it. */
2320 memcpy (string_data (s) + bytoff, newstr, newlen); 2307 memcpy (string_data (s) + bytoff, newstr, newlen);
2591 2578
2592 Lisp_Object 2579 Lisp_Object
2593 make_pure_string (CONST Bufbyte *data, Bytecount length, 2580 make_pure_string (CONST Bufbyte *data, Bytecount length,
2594 Lisp_Object plist, int no_need_to_copy_data) 2581 Lisp_Object plist, int no_need_to_copy_data)
2595 { 2582 {
2596 Lisp_Object new; 2583 Lisp_String *s;
2597 struct Lisp_String *s; 2584 size_t size = sizeof (Lisp_String) +
2598 size_t size = sizeof (struct Lisp_String) +
2599 (no_need_to_copy_data ? 0 : (length + 1)); /* + 1 for terminating 0 */ 2585 (no_need_to_copy_data ? 0 : (length + 1)); /* + 1 for terminating 0 */
2600 size = ALIGN_SIZE (size, ALIGNOF (Lisp_Object)); 2586 size = ALIGN_SIZE (size, ALIGNOF (Lisp_Object));
2601 2587
2602 if (symbols_initialized && !pure_lossage) 2588 if (symbols_initialized && !pure_lossage)
2603 { 2589 {
2605 Lisp_Object tem = oblookup (Vobarray, data, length); 2591 Lisp_Object tem = oblookup (Vobarray, data, length);
2606 if (SYMBOLP (tem)) 2592 if (SYMBOLP (tem))
2607 { 2593 {
2608 s = XSYMBOL (tem)->name; 2594 s = XSYMBOL (tem)->name;
2609 if (!PURIFIED (s)) abort (); 2595 if (!PURIFIED (s)) abort ();
2610 XSETSTRING (new, s); 2596
2611 return new; 2597 {
2598 Lisp_Object string;
2599 XSETSTRING (string, s);
2600 return string;
2601 }
2612 } 2602 }
2613 } 2603 }
2614 2604
2615 if (!check_purespace (size)) 2605 if (!check_purespace (size))
2616 return make_string (data, length); 2606 return make_string (data, length);
2617 2607
2618 s = (struct Lisp_String *) (PUREBEG + pure_bytes_used); 2608 s = (Lisp_String *) (PUREBEG + pure_bytes_used);
2619 #ifdef LRECORD_STRING 2609 #ifdef LRECORD_STRING
2620 set_lheader_implementation (&(s->lheader), lrecord_string); 2610 set_lheader_implementation (&(s->lheader), lrecord_string);
2621 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION 2611 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
2622 s->lheader.pure = 1; 2612 s->lheader.pure = 1;
2623 #endif 2613 #endif
2627 { 2617 {
2628 set_string_data (s, (Bufbyte *) data); 2618 set_string_data (s, (Bufbyte *) data);
2629 } 2619 }
2630 else 2620 else
2631 { 2621 {
2632 set_string_data (s, (Bufbyte *) s + sizeof (struct Lisp_String)); 2622 set_string_data (s, (Bufbyte *) s + sizeof (Lisp_String));
2633 memcpy (string_data (s), data, length); 2623 memcpy (string_data (s), data, length);
2634 set_string_byte (s, length, 0); 2624 set_string_byte (s, length, 0);
2635 } 2625 }
2636 s->plist = Qnil; 2626 s->plist = Qnil;
2637 pure_bytes_used += size; 2627 pure_bytes_used += size;
2643 #endif /* PURESTAT */ 2633 #endif /* PURESTAT */
2644 2634
2645 /* Do this after the official "completion" of the purecopying. */ 2635 /* Do this after the official "completion" of the purecopying. */
2646 s->plist = Fpurecopy (plist); 2636 s->plist = Fpurecopy (plist);
2647 2637
2648 XSETSTRING (new, s); 2638 {
2649 return new; 2639 Lisp_Object string;
2640 XSETSTRING (string, s);
2641 return string;
2642 }
2650 } 2643 }
2651 2644
2652 2645
2653 Lisp_Object 2646 Lisp_Object
2654 make_pure_pname (CONST Bufbyte *data, Bytecount length, 2647 make_pure_pname (CONST Bufbyte *data, Bytecount length,
2666 2659
2667 2660
2668 Lisp_Object 2661 Lisp_Object
2669 pure_cons (Lisp_Object car, Lisp_Object cdr) 2662 pure_cons (Lisp_Object car, Lisp_Object cdr)
2670 { 2663 {
2671 Lisp_Object new; 2664 Lisp_Cons *c;
2672 struct Lisp_Cons *c; 2665
2673 2666 if (!check_purespace (sizeof (Lisp_Cons)))
2674 if (!check_purespace (sizeof (struct Lisp_Cons)))
2675 return Fcons (Fpurecopy (car), Fpurecopy (cdr)); 2667 return Fcons (Fpurecopy (car), Fpurecopy (cdr));
2676 2668
2677 c = (struct Lisp_Cons *) (PUREBEG + pure_bytes_used); 2669 c = (Lisp_Cons *) (PUREBEG + pure_bytes_used);
2678 #ifdef LRECORD_CONS 2670 #ifdef LRECORD_CONS
2679 set_lheader_implementation (&(c->lheader), lrecord_cons); 2671 set_lheader_implementation (&(c->lheader), lrecord_cons);
2680 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION 2672 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
2681 c->lheader.pure = 1; 2673 c->lheader.pure = 1;
2682 #endif 2674 #endif
2683 #endif 2675 #endif
2684 pure_bytes_used += sizeof (struct Lisp_Cons); 2676 pure_bytes_used += sizeof (Lisp_Cons);
2685 bump_purestat (&purestat_cons, sizeof (struct Lisp_Cons)); 2677 bump_purestat (&purestat_cons, sizeof (Lisp_Cons));
2686 2678
2687 c->car = Fpurecopy (car); 2679 c->car = Fpurecopy (car);
2688 c->cdr = Fpurecopy (cdr); 2680 c->cdr = Fpurecopy (cdr);
2689 XSETCONS (new, c); 2681
2690 return new; 2682 {
2683 Lisp_Object cons;
2684 XSETCONS (cons, c);
2685 return cons;
2686 }
2691 } 2687 }
2692 2688
2693 Lisp_Object 2689 Lisp_Object
2694 pure_list (int nargs, Lisp_Object *args) 2690 pure_list (int nargs, Lisp_Object *args)
2695 { 2691 {
2754 #endif /* LISP_FLOAT_TYPE */ 2750 #endif /* LISP_FLOAT_TYPE */
2755 2751
2756 Lisp_Object 2752 Lisp_Object
2757 make_pure_vector (size_t len, Lisp_Object init) 2753 make_pure_vector (size_t len, Lisp_Object init)
2758 { 2754 {
2759 Lisp_Object new;
2760 Lisp_Vector *v; 2755 Lisp_Vector *v;
2761 size_t size = offsetof (Lisp_Vector, contents[len]); 2756 size_t size = STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents, len);
2762 2757
2763 init = Fpurecopy (init); 2758 init = Fpurecopy (init);
2764 2759
2765 if (!check_purespace (size)) 2760 if (!check_purespace (size))
2766 return make_vector (len, init); 2761 return make_vector (len, init);
2778 v->size = len; 2773 v->size = len;
2779 2774
2780 for (size = 0; size < len; size++) 2775 for (size = 0; size < len; size++)
2781 v->contents[size] = init; 2776 v->contents[size] = init;
2782 2777
2783 XSETVECTOR (new, v); 2778 {
2784 return new; 2779 Lisp_Object vector;
2780 XSETVECTOR (vector, v);
2781 return vector;
2782 }
2785 } 2783 }
2786 2784
2787 #if 0 2785 #if 0
2788 /* Presently unused */ 2786 /* Presently unused */
2789 void * 2787 void *
3336 ? implementation->size_in_bytes_method (lheader) 3334 ? implementation->size_in_bytes_method (lheader)
3337 : implementation->static_size; 3335 : implementation->static_size;
3338 } 3336 }
3339 #ifndef LRECORD_VECTOR 3337 #ifndef LRECORD_VECTOR
3340 else if (VECTORP (obj)) 3338 else if (VECTORP (obj))
3341 return offsetof (Lisp_Vector, contents[XVECTOR_LENGTH (obj)]); 3339 return STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents, XVECTOR_LENGTH (obj));
3342 #endif /* !LRECORD_VECTOR */ 3340 #endif /* !LRECORD_VECTOR */
3343 3341
3344 #ifndef LRECORD_CONS 3342 #ifndef LRECORD_CONS
3345 else if (CONSP (obj)) 3343 else if (CONSP (obj))
3346 return sizeof (struct Lisp_Cons); 3344 return sizeof (struct Lisp_Cons);
3521 { 3519 {
3522 len = - (len + 1); 3520 len = - (len + 1);
3523 v->size = len; 3521 v->size = len;
3524 total_size += len; 3522 total_size += len;
3525 total_storage += 3523 total_storage +=
3526 MALLOC_OVERHEAD + offsetof (Lisp_Vector, contents[len + 1]); 3524 MALLOC_OVERHEAD +
3525 STRETCHY_STRUCT_SIZEOF (Lisp_Vector, contents, len + 1);
3527 num_used++; 3526 num_used++;
3528 prev = &(vector_next (v)); 3527 prev = &(vector_next (v));
3529 vector = *prev; 3528 vector = *prev;
3530 } 3529 }
3531 else 3530 else
3561 if (MARKED_RECORD_P (bit_vector)) 3560 if (MARKED_RECORD_P (bit_vector))
3562 { 3561 {
3563 UNMARK_RECORD_HEADER (&(v->lheader)); 3562 UNMARK_RECORD_HEADER (&(v->lheader));
3564 total_size += len; 3563 total_size += len;
3565 total_storage += 3564 total_storage +=
3566 MALLOC_OVERHEAD 3565 MALLOC_OVERHEAD +
3567 + offsetof (Lisp_Bit_Vector, bits[BIT_VECTOR_LONG_STORAGE (len)]); 3566 STRETCHY_STRUCT_SIZEOF (Lisp_Bit_Vector, bits,
3567 BIT_VECTOR_LONG_STORAGE (len));
3568 num_used++; 3568 num_used++;
3569 prev = &(bit_vector_next (v)); 3569 prev = &(bit_vector_next (v));
3570 bit_vector = *prev; 3570 bit_vector = *prev;
3571 } 3571 }
3572 else 3572 else