Mercurial > hg > xemacs-beta
annotate src/array.c @ 5891:a0e751d6c3ad
Import the #'clear-string API from GNU, use it in tls.c
src/ChangeLog addition:
2015-04-18 Aidan Kehoe <kehoea@parhasard.net>
* sequence.c (Fclear_string): New, API from GNU. Zero a string's
contents, making sure the text is not kept around even when the
string's data is reallocated because of a changed character
length.
* sequence.c (syms_of_sequence): Make it available to Lisp.
* lisp.h: Make it available to C code.
* tls.c (nss_pk11_password): Use it.
* tls.c (gnutls_pk11_password): Use it.
* tls.c (openssl_password): Use it.
tests/ChangeLog addition:
2015-04-18 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test #'clear-string, just added. Unfortunately there's no way to
be certain from Lisp that the old password data has been erased
after realloc; it may be worth adding a test to tests.c, but
*we'll be reading memory we shouldn't be*, so that gives me pause.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 18 Apr 2015 23:00:14 +0100 |
parents | f7abcda06b1b |
children |
rev | line source |
---|---|
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1 /* Support for dynarrs and other types of dynamic arrays. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
2 Copyright (c) 1994, 1995 Free Software Foundation, Inc. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
3 Copyright (c) 1993, 1995 Sun Microsystems, Inc. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
4 Copyright (c) 1995, 1996, 2000, 2002, 2003, 2004, 2005, 2010 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5170
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
428 | 9 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5170
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5170
diff
changeset
|
11 option) any later version. |
428 | 12 |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5170
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 20 |
21 /* Synched up with: Not in FSF. */ | |
22 | |
23 /* Written by Ben Wing, December 1993. */ | |
24 | |
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
25 #include <config.h> |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
26 #include "lisp.h" |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
27 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
28 #include "insdel.h" |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
29 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
30 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
31 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
32 /* "dynarr" a.k.a. dynamic array */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
33 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
34 |
428 | 35 /* |
5038 | 36 A "dynamic array" or "dynarr" is a contiguous array of fixed-size elements |
37 where there is no upper limit (except available memory) on the number of | |
38 elements in the array. Because the elements are maintained contiguously, | |
39 space is used efficiently (no per-element pointers necessary) and random | |
40 access to a particular element is in constant time. At any one point, the | |
41 block of memory that holds the array has an upper limit; if this limit is | |
42 exceeded, the memory is realloc()ed into a new array that is twice as big. | |
43 Assuming that the time to grow the array is on the order of the new size of | |
44 the array block, this scheme has a provably constant amortized time | |
45 \(i.e. average time over all additions). | |
428 | 46 |
47 When you add elements or retrieve elements, pointers are used. Note that | |
48 the element itself (of whatever size it is), and not the pointer to it, | |
49 is stored in the array; thus you do not have to allocate any heap memory | |
50 on your own. Also, returned pointers are only guaranteed to be valid | |
51 until the next operation that changes the length of the array. | |
52 | |
53 This is a container object. Declare a dynamic array of a specific type | |
54 as follows: | |
55 | |
2367 | 56 typedef struct |
57 { | |
58 Dynarr_declare (mytype); | |
59 } mytype_dynarr; | |
428 | 60 |
61 Use the following functions/macros: | |
62 | |
5038 | 63 |
64 ************* Dynarr creation ************* | |
65 | |
428 | 66 void *Dynarr_new(type) |
67 [MACRO] Create a new dynamic-array object, with each element of the | |
68 specified type. The return value is cast to (type##_dynarr). | |
69 This requires following the convention that types are declared in | |
70 such a way that this type concatenation works. In particular, TYPE | |
5038 | 71 must be a symbol, not an arbitrary C type. To make dynarrs of |
72 complex types, a typedef must be declared, e.g. | |
73 | |
74 typedef unsigned char *unsigned_char_ptr; | |
75 | |
76 and then you can say | |
77 | |
78 unsigned_char_ptr_dynarr *dyn = Dynarr_new (unsigned_char_ptr); | |
79 | |
80 void *Dynarr_new2(dynarr_type, type) | |
81 [MACRO] Create a new dynamic-array object, with each element of the | |
82 specified type. The array itself is of type DYNARR_TYPE. This makes | |
83 it possible to create dynarrs over complex types without the need | |
84 to create typedefs, as described above. Use is as follows: | |
85 | |
86 ucharptr_dynarr *dyn = Dynarr_new2 (ucharptr_dynarr *, unsigned char *); | |
87 | |
88 Dynarr_free(d) | |
89 Destroy a dynamic array and the memory allocated to it. | |
90 | |
91 ************* Dynarr access ************* | |
92 | |
93 type Dynarr_at(d, i) | |
94 [MACRO] Return the element at the specified index. The index must be | |
95 between 0 and Dynarr_largest(d), inclusive. With error-checking | |
96 enabled, bounds checking on the index is in the form of asserts() -- | |
97 an out-of-bounds index causes an abort. The element itself is | |
98 returned, not a pointer to it. | |
99 | |
100 type *Dynarr_atp(d, i) | |
101 [MACRO] Return a pointer to the element at the specified index. | |
102 Restrictions and bounds checking on the index is as for Dynarr_at. | |
103 The pointer may not be valid after an element is added to or | |
104 (conceivably) removed from the array, because this may trigger a | |
105 realloc() performed on the underlying dynarr storage, which may | |
106 involve moving the entire underlying storage to a new location in | |
107 memory. | |
108 | |
109 type *Dynarr_begin(d) | |
110 [MACRO] Return a pointer to the first element in the dynarr. See | |
111 Dynarr_atp() for warnings about when the pointer might become invalid. | |
112 | |
113 type *Dynarr_lastp(d) | |
114 [MACRO] Return a pointer to the last element in the dynarr. See | |
115 Dynarr_atp() for warnings about when the pointer might become invalid. | |
116 | |
117 type *Dynarr_past_lastp(d) | |
118 [MACRO] Return a pointer to the beginning of the element just past the | |
119 last one. WARNING: This may not point to valid memory; however, the | |
120 byte directly before will be pointer will be valid memory. This macro | |
121 might be useful for various reasons, e.g. as a stopping point in a loop | |
122 (although Dynarr_lastp() could be used just as well) or as a place to | |
123 start writing elements if Dynarr_length() < Dynarr_largest(). | |
124 | |
125 ************* Dynarr length/size retrieval and setting ************* | |
126 | |
127 int Dynarr_length(d) | |
128 [MACRO] Return the number of elements currently in a dynamic array. | |
129 | |
130 int Dynarr_largest(d) | |
131 [MACRO] Return the maximum value that Dynarr_length(d) would | |
132 ever have returned. This is used esp. in the redisplay code, | |
133 which reuses dynarrs for performance reasons. | |
134 | |
135 int Dynarr_max(d) | |
136 [MACRO] Return the maximum number of elements that can fit in the | |
137 dynarr before it needs to be resized. | |
138 | |
139 Note that Dynarr_length(d) <= Dynarr_largest(d) <= Dynarr_max(d). | |
140 | |
141 Bytecount Dynarr_sizeof(d) | |
142 [MACRO] Return the total size of the elements currently in dynarr | |
143 D. This | |
144 | |
145 Dynarr_set_lengthr(d, len) | |
146 [MACRO] Set the length of D to LEN, which must be between 0 and | |
147 Dynarr_largest(d), inclusive. With error-checking enabled, an | |
148 assertion failure will result from trying to set the length | |
149 to less than zero or greater than Dynarr_largest(d). The | |
150 restriction to Dynarr_largest() is to ensure that | |
151 | |
152 Dynarr_set_length(d, len) | |
153 [MACRO] Set the length of D to LEN, resizing the dynarr as | |
154 necessary to make sure enough space is available. there are no | |
155 restrictions on LEN other than available memory and that it must | |
156 be at least 0. Note that | |
157 | |
158 Dynarr_set_length_and_zero(d, len) | |
159 [MACRO] Like Dynarr_set_length(d, len) but also, if increasing | |
160 the length, zero out the memory between the old and new lengths, | |
161 i.e. starting just past the previous last element and up through | |
162 the new last element. | |
163 | |
164 Dynarr_incrementr(d) | |
165 [MACRO] Increments the length of D by 1. Equivalent to | |
166 Dynarr_set_lengthr(d, Dynarr_length(d) + 1). | |
167 | |
168 Dynarr_increment(d) | |
169 [MACRO] Increments the length of D by 1. Equivalent to | |
170 Dynarr_set_length(d, Dynarr_length(d) + 1). | |
171 | |
172 Dynarr_reset(d) | |
173 [MACRO] Reset the length of a dynamic array to 0. | |
174 | |
175 Dynarr_resize(d, maxval) | |
176 Resize the internal dynarr storage to so that it can hold at least | |
177 MAXVAL elements. Resizing is done using a geometric series | |
178 (repeatedly multiply the old maximum by a constant, normally 1.5, | |
179 till a large enough size is reached), so this will be efficient | |
180 even if resizing larger by one element at a time. This is mostly | |
181 an internal function. | |
182 | |
183 | |
184 | |
185 ************* Adding/deleting elements to/from a dynarr ************* | |
428 | 186 |
187 Dynarr_add(d, el) | |
188 [MACRO] Add an element to the end of a dynamic array. EL is a pointer | |
189 to the element; the element itself is stored in the array, however. | |
190 No function call is performed unless the array needs to be resized. | |
191 | |
192 Dynarr_add_many(d, base, len) | |
193 [MACRO] Add LEN elements to the end of the dynamic array. The elements | |
771 | 194 should be contiguous in memory, starting at BASE. If BASE if NULL, |
195 just make space for the elements; don't actually add them. | |
428 | 196 |
5038 | 197 Dynarr_prepend_many(d, base, len) |
198 [MACRO] Prepend LEN elements to the beginning of the dynamic array. | |
428 | 199 The elements should be contiguous in memory, starting at BASE. |
771 | 200 If BASE if NULL, just make space for the elements; don't actually |
201 add them. | |
428 | 202 |
5038 | 203 Dynarr_insert_many(d, base, len, pos) |
428 | 204 Insert LEN elements to the dynamic array starting at position |
5038 | 205 POS. The elements should be contiguous in memory, starting at BASE. |
771 | 206 If BASE if NULL, just make space for the elements; don't actually |
207 add them. | |
208 | |
5038 | 209 type Dynarr_pop(d) |
210 [MACRO] Pop the last element off the dynarr and return it. | |
211 | |
771 | 212 Dynarr_delete(d, i) |
213 [MACRO] Delete an element from the dynamic array at position I. | |
214 | |
5038 | 215 Dynarr_delete_many(d, pos, len) |
771 | 216 Delete LEN elements from the dynamic array starting at position |
5038 | 217 POS. |
218 | |
219 Dynarr_zero_many(d, pos, len) | |
220 Zero out LEN elements in the dynarr D starting at position POS. | |
771 | 221 |
222 Dynarr_delete_by_pointer(d, p) | |
223 [MACRO] Delete an element from the dynamic array at pointer P, | |
224 which must point within the block of memory that stores the data. | |
225 P should be obtained using Dynarr_atp(). | |
428 | 226 |
5038 | 227 ************* Dynarr locking ************* |
428 | 228 |
5038 | 229 Dynarr_lock(d) |
230 Lock the dynarr against further locking or writing. With error-checking | |
231 enabled, any attempts to write into a locked dynarr or re-lock an | |
232 already locked one will cause an assertion failure and abort. | |
428 | 233 |
5038 | 234 Dynarr_unlock(d) |
235 Unlock a locked dynarr, allowing writing into it. | |
428 | 236 |
5038 | 237 ************* Dynarr global variables ************* |
428 | 238 |
239 Dynarr_min_size | |
440 | 240 Minimum allowable size for a dynamic array when it is resized. |
428 | 241 |
242 */ | |
243 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
244 static const struct memory_description const_Ascbyte_ptr_description_1[] = { |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
245 { XD_ASCII_STRING, 0 }, |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
246 { XD_END } |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
247 }; |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
248 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
249 const struct sized_memory_description const_Ascbyte_ptr_description = { |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
250 sizeof (const Ascbyte *), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
251 const_Ascbyte_ptr_description_1 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
252 }; |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
253 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
254 static const struct memory_description const_Ascbyte_ptr_dynarr_description_1[] = { |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
255 XD_DYNARR_DESC (const_Ascbyte_ptr_dynarr, &const_Ascbyte_ptr_description), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
256 { XD_END } |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
257 }; |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
258 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
259 const struct sized_memory_description const_Ascbyte_ptr_dynarr_description = { |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
260 sizeof (const_Ascbyte_ptr_dynarr), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
261 const_Ascbyte_ptr_dynarr_description_1 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
262 }; |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
263 |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
264 |
5038 | 265 static Elemcount Dynarr_min_size = 8; |
428 | 266 |
267 static void | |
5038 | 268 Dynarr_realloc (Dynarr *dy, Elemcount new_size) |
428 | 269 { |
270 if (DUMPEDP (dy->base)) | |
271 { | |
5038 | 272 void *new_base = malloc (new_size * Dynarr_elsize (dy)); |
3210 | 273 memcpy (new_base, dy->base, |
4967 | 274 (Dynarr_max (dy) < new_size ? Dynarr_max (dy) : new_size) * |
5038 | 275 Dynarr_elsize (dy)); |
428 | 276 dy->base = new_base; |
277 } | |
278 else | |
5038 | 279 dy->base = xrealloc (dy->base, new_size * Dynarr_elsize (dy)); |
428 | 280 } |
281 | |
282 void * | |
5038 | 283 Dynarr_newf (Bytecount elsize) |
428 | 284 { |
285 Dynarr *d = xnew_and_zero (Dynarr); | |
5038 | 286 d->elsize_ = elsize; |
428 | 287 |
288 return d; | |
289 } | |
290 | |
3092 | 291 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
292 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("dynarr", dynarr, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
293 0, 0, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
294 Dynarr); |
3092 | 295 |
296 static void | |
5038 | 297 Dynarr_lisp_realloc (Dynarr *dy, Elemcount new_size) |
3092 | 298 { |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
299 void *new_base = |
5126 | 300 XPNTR (alloc_sized_lrecord_array (Dynarr_elsize (dy), new_size, |
301 dy->lisp_imp)); | |
3092 | 302 if (dy->base) |
303 memcpy (new_base, dy->base, | |
4967 | 304 (Dynarr_max (dy) < new_size ? Dynarr_max (dy) : new_size) * |
5038 | 305 Dynarr_elsize (dy)); |
3092 | 306 dy->base = new_base; |
307 } | |
308 | |
309 void * | |
5038 | 310 Dynarr_lisp_newf (Bytecount elsize, |
3092 | 311 const struct lrecord_implementation *dynarr_imp, |
312 const struct lrecord_implementation *imp) | |
313 { | |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
314 Dynarr *d = (Dynarr *) XPNTR (alloc_sized_lrecord (sizeof (Dynarr), |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
315 dynarr_imp)); |
5038 | 316 d->elsize_ = elsize; |
3092 | 317 d->lisp_imp = imp; |
318 | |
319 return d; | |
320 } | |
321 #endif /* not NEW_GC */ | |
322 | |
428 | 323 void |
2367 | 324 Dynarr_resize (void *d, Elemcount size) |
428 | 325 { |
5038 | 326 Elemcount newsize; |
428 | 327 double multiplier; |
1318 | 328 Dynarr *dy = (Dynarr *) Dynarr_verify (d); |
428 | 329 |
4967 | 330 if (Dynarr_max (dy) <= 8) |
428 | 331 multiplier = 2; |
332 else | |
333 multiplier = 1.5; | |
334 | |
4967 | 335 for (newsize = Dynarr_max (dy); newsize < size;) |
5038 | 336 newsize = max (Dynarr_min_size, (Elemcount) (multiplier * newsize)); |
428 | 337 |
338 /* Don't do anything if the array is already big enough. */ | |
4967 | 339 if (newsize > Dynarr_max (dy)) |
428 | 340 { |
3092 | 341 #ifdef NEW_GC |
342 if (dy->lisp_imp) | |
343 Dynarr_lisp_realloc (dy, newsize); | |
344 else | |
3210 | 345 Dynarr_realloc (dy, newsize); |
3092 | 346 #else /* not NEW_GC */ |
3210 | 347 Dynarr_realloc (dy, newsize); |
3092 | 348 #endif /* not NEW_GC */ |
4967 | 349 dy->max_ = newsize; |
428 | 350 } |
351 } | |
352 | |
5038 | 353 /* Add a number of contiguous elements to the array starting at POS. */ |
354 | |
428 | 355 void |
5038 | 356 Dynarr_insert_many (void *d, const void *base, Elemcount len, Elemcount pos) |
428 | 357 { |
4967 | 358 Dynarr *dy = Dynarr_verify_mod (d); |
5038 | 359 Elemcount old_len = Dynarr_length (dy); |
4967 | 360 |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
361 /* #### This could conceivably be wrong, if code wants to access stuff |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
362 between len and largest. */ |
5038 | 363 dynarr_checking_assert (pos >= 0 && pos <= old_len); |
364 dynarr_checking_assert (len >= 0); | |
365 Dynarr_increase_length (dy, old_len + len); | |
428 | 366 |
5038 | 367 if (pos != old_len) |
428 | 368 { |
5038 | 369 memmove ((Rawbyte *) dy->base + (pos + len)*Dynarr_elsize (dy), |
370 (Rawbyte *) dy->base + pos*Dynarr_elsize (dy), | |
371 (old_len - pos)*Dynarr_elsize (dy)); | |
428 | 372 } |
4967 | 373 /* Some functions call us with a value of 0 to mean "reserve space but |
374 don't write into it" */ | |
5038 | 375 if (base) |
376 memcpy ((Rawbyte *) dy->base + pos*Dynarr_elsize (dy), base, | |
377 len*Dynarr_elsize (dy)); | |
428 | 378 } |
379 | |
380 void | |
5038 | 381 Dynarr_delete_many (void *d, Elemcount pos, Elemcount len) |
428 | 382 { |
4967 | 383 Dynarr *dy = Dynarr_verify_mod (d); |
428 | 384 |
5038 | 385 dynarr_checking_assert (pos >= 0 && len >= 0 && |
386 pos + len <= Dynarr_length (dy)); | |
4967 | 387 |
5038 | 388 memmove ((Rawbyte *) dy->base + pos*Dynarr_elsize (dy), |
389 (Rawbyte *) dy->base + (pos + len)*Dynarr_elsize (dy), | |
390 (Dynarr_length (dy) - pos - len)*Dynarr_elsize (dy)); | |
4967 | 391 |
392 Dynarr_set_length_1 (dy, Dynarr_length (dy) - len); | |
428 | 393 } |
394 | |
395 void | |
396 Dynarr_free (void *d) | |
397 { | |
398 Dynarr *dy = (Dynarr *) d; | |
399 | |
3092 | 400 #ifdef NEW_GC |
401 if (dy->base && !DUMPEDP (dy->base)) | |
402 { | |
4117 | 403 if (!dy->lisp_imp) |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
404 { |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
405 xfree (dy->base); |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
406 dy->base = 0; |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
407 } |
3092 | 408 } |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
409 if (!DUMPEDP (dy)) |
3092 | 410 { |
4117 | 411 if (!dy->lisp_imp) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
412 xfree (dy); |
3092 | 413 } |
414 #else /* not NEW_GC */ | |
428 | 415 if (dy->base && !DUMPEDP (dy->base)) |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
416 { |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
417 xfree (dy->base); |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
418 dy->base = 0; |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5168
diff
changeset
|
419 } |
428 | 420 if(!DUMPEDP (dy)) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
421 xfree (dy); |
3092 | 422 #endif /* not NEW_GC */ |
428 | 423 } |
424 | |
425 #ifdef MEMORY_USAGE_STATS | |
426 | |
5038 | 427 /* Return memory usage for dynarr D. The returned value is the total |
428 amount of bytes actually being used for the dynarr, including all | |
429 overhead. The extra amount of space in the dynarr that is | |
428 | 430 allocated beyond what was requested is returned in DYNARR_OVERHEAD |
431 in STATS. The extra amount of space that malloc() allocates beyond | |
432 what was requested of it is returned in MALLOC_OVERHEAD in STATS. | |
433 See the comment above the definition of this structure. */ | |
434 | |
665 | 435 Bytecount |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
436 Dynarr_memory_usage (void *d, struct usage_stats *stats) |
428 | 437 { |
665 | 438 Bytecount total = 0; |
428 | 439 Dynarr *dy = (Dynarr *) d; |
440 | |
441 /* We have to be a bit tricky here because not all of the | |
442 memory that malloc() will claim as "requested" was actually | |
443 requested. */ | |
444 | |
445 if (dy->base) | |
446 { | |
4967 | 447 Bytecount malloc_used = |
5038 | 448 malloced_storage_size (dy->base, Dynarr_elsize (dy) * Dynarr_max (dy), |
449 0); | |
450 /* #### This may or may not be correct. Some dynarrs would | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
451 prefer that we use dy->len instead of dy->largest here. */ |
5038 | 452 Bytecount was_requested = Dynarr_elsize (dy) * Dynarr_largest (dy); |
4967 | 453 Bytecount dynarr_overhead = |
5038 | 454 Dynarr_elsize (dy) * (Dynarr_max (dy) - Dynarr_largest (dy)); |
428 | 455 |
456 total += malloc_used; | |
457 stats->was_requested += was_requested; | |
458 stats->dynarr_overhead += dynarr_overhead; | |
459 /* And the remainder must be malloc overhead. */ | |
460 stats->malloc_overhead += | |
461 malloc_used - was_requested - dynarr_overhead; | |
462 } | |
463 | |
464 total += malloced_storage_size (d, sizeof (*dy), stats); | |
465 | |
466 return total; | |
467 } | |
468 | |
469 #endif /* MEMORY_USAGE_STATS */ | |
2367 | 470 |
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
471 |
5729
f7abcda06b1b
Since stack_like_{malloc,free}() are only used when WIN32_ANY,
Jerry James <james@xemacs.org>
parents:
5402
diff
changeset
|
472 #ifdef WIN32_ANY |
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
473 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
474 /* stack-like allocation */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
475 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
476 |
2367 | 477 /* Version of malloc() that will be extremely efficient when allocation |
478 nearly always occurs in LIFO (stack) order. | |
479 | |
480 #### Perhaps shouldn't be in this file, but where else? */ | |
481 | |
482 typedef struct | |
483 { | |
484 Dynarr_declare (char_dynarr *); | |
485 } char_dynarr_dynarr; | |
486 | |
487 char_dynarr_dynarr *stack_like_free_list; | |
488 char_dynarr_dynarr *stack_like_in_use_list; | |
489 | |
490 void * | |
491 stack_like_malloc (Bytecount size) | |
492 { | |
493 char_dynarr *this_one; | |
494 if (!stack_like_free_list) | |
495 { | |
496 stack_like_free_list = Dynarr_new2 (char_dynarr_dynarr, | |
497 char_dynarr *); | |
498 stack_like_in_use_list = Dynarr_new2 (char_dynarr_dynarr, | |
499 char_dynarr *); | |
500 } | |
501 | |
502 if (Dynarr_length (stack_like_free_list) > 0) | |
503 this_one = Dynarr_pop (stack_like_free_list); | |
504 else | |
505 this_one = Dynarr_new (char); | |
506 Dynarr_add (stack_like_in_use_list, this_one); | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
507 Dynarr_reset (this_one); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
508 Dynarr_add_many (this_one, 0, size); |
4967 | 509 return Dynarr_begin (this_one); |
2367 | 510 } |
511 | |
512 void | |
513 stack_like_free (void *val) | |
514 { | |
5038 | 515 Elemcount len = Dynarr_length (stack_like_in_use_list); |
2367 | 516 assert (len > 0); |
517 /* The vast majority of times, we will be called in a last-in first-out | |
518 order, and the item at the end of the list will be the one we're | |
519 looking for, so just check for this first and avoid any function | |
520 calls. */ | |
4967 | 521 if (Dynarr_begin (Dynarr_at (stack_like_in_use_list, len - 1)) == val) |
2367 | 522 { |
523 char_dynarr *this_one = Dynarr_pop (stack_like_in_use_list); | |
524 Dynarr_add (stack_like_free_list, this_one); | |
525 } | |
526 else | |
527 { | |
528 /* Find the item and delete it. */ | |
529 int i; | |
530 assert (len >= 2); | |
531 for (i = len - 2; i >= 0; i--) | |
4967 | 532 if (Dynarr_begin (Dynarr_at (stack_like_in_use_list, i)) == |
2367 | 533 val) |
534 { | |
535 char_dynarr *this_one = Dynarr_at (stack_like_in_use_list, i); | |
536 Dynarr_add (stack_like_free_list, this_one); | |
537 Dynarr_delete (stack_like_in_use_list, i); | |
538 return; | |
539 } | |
540 | |
2500 | 541 ABORT (); |
2367 | 542 } |
543 } | |
5729
f7abcda06b1b
Since stack_like_{malloc,free}() are only used when WIN32_ANY,
Jerry James <james@xemacs.org>
parents:
5402
diff
changeset
|
544 #endif /* WIN32_ANY */ |
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
545 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
546 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
547 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
548 /* Generalized gap array */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
549 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
550 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
551 /* A "gap array" is an array that has a "gap" somewhere in the middle of it, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
552 so that insertions and deletions near the gap -- or in general, highly |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
553 localized insertions and deletions -- are very fast. Inserting or |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
554 deleting works by first moving the gap to the insertion or deletion |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
555 position and then shortening or lengthening the gap as necessary. The |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
556 idea comes from the gap used in storing text in a buffer. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
557 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
558 The gap array interface differs in a number of ways from dynarrs (#### |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
559 and should be changed so that it works the same as dynarrs): |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
560 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
561 (1) There aren't separate type-specific gap array types. As a result, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
562 operations like gap_array_at() require that the type be specified as |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
563 one of the arguments. It is often more convenient to use a macro |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
564 wrapper around this operation. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
565 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
566 (2) The gap array type is itself a stretchy array rather than using a |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
567 separate block of memory to store the array. This means that certain |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
568 operations (especially insertions) may relocate the the gap array, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
569 and as a result return a pointer to the (possibly) moved gap array, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
570 which must be stored back into the location where the gap array |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
571 pointer resides. This also means that the caller must worry about |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
572 cloning the gap array in the case where it has been dumped, or you |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
573 will get an ABORT() inside of xrealloc(). |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
574 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
575 (3) Fewer operations are available than for dynarrs, and may have |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
576 different names and/or different calling conventions. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
577 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
578 (4) The mechanism for creating "Lisp-object gap arrays" isn't completely |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
579 developed. Currently it's only possible to create a gap-array Lisp |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
580 object that wraps Lisp_Object pointers (not Lisp object structures |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
581 directly), and only under NEW_GC. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
582 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
583 (5) Gap arrays have a concept of a "gap array marker" that properly |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
584 tracks insertions and deletions; no such thing exists in dynarrs. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
585 It exists in gap arrays because it's necessary for their use in |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
586 implementing extent lists. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
587 */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
588 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
589 extern const struct sized_memory_description gap_array_marker_description; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
590 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
591 static const struct memory_description gap_array_marker_description_1[] = { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
592 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
593 { XD_LISP_OBJECT, offsetof (Gap_Array_Marker, next) }, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
594 #else /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
595 { XD_BLOCK_PTR, offsetof (Gap_Array_Marker, next), 1, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
596 { &gap_array_marker_description } }, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
597 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
598 { XD_END } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
599 }; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
600 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
601 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
602 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("gap-array-marker", gap_array_marker, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
603 0, gap_array_marker_description_1, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
604 struct gap_array_marker); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
605 #else /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
606 const struct sized_memory_description gap_array_marker_description = { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
607 sizeof (Gap_Array_Marker), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
608 gap_array_marker_description_1 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
609 }; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
610 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
611 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
612 static const struct memory_description lispobj_gap_array_description_1[] = { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
613 XD_GAP_ARRAY_DESC (&lisp_object_description), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
614 { XD_END } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
615 }; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
616 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
617 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
618 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
619 static Bytecount |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
620 size_gap_array (Lisp_Object obj) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
621 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
622 Gap_Array *ga = XGAP_ARRAY (obj); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
623 return gap_array_byte_size (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
624 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
625 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
626 DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT ("gap-array", gap_array, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
627 0, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
628 lispobj_gap_array_description_1, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
629 size_gap_array, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
630 struct gap_array); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
631 #else /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
632 const struct sized_memory_description lispobj_gap_array_description = { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
633 0, lispobj_gap_array_description_1 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
634 }; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
635 #endif /* (not) NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
636 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
637 #ifndef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
638 static Gap_Array_Marker *gap_array_marker_freelist; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
639 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
640 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
641 /* This generalizes the "array with a gap" model used to store buffer |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
642 characters. This is based on the stuff in insdel.c and should |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
643 probably be merged with it. This is not extent-specific and should |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
644 perhaps be moved into a separate file. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
645 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
646 /* ------------------------------- */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
647 /* internal functions */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
648 /* ------------------------------- */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
649 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
650 /* Adjust the gap array markers in the range (FROM, TO]. Parallel to |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
651 adjust_markers() in insdel.c. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
652 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
653 static void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
654 gap_array_adjust_markers (Gap_Array *ga, Memxpos from, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
655 Memxpos to, Elemcount amount) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
656 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
657 Gap_Array_Marker *m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
658 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
659 for (m = ga->markers; m; m = m->next) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
660 m->pos = do_marker_adjustment (m->pos, from, to, amount); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
661 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
662 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
663 static void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
664 gap_array_recompute_derived_values (Gap_Array *ga) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
665 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
666 ga->offset_past_gap = ga->elsize * (ga->gap + ga->gapsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
667 ga->els_past_gap = ga->numels - ga->gap; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
668 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
669 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
670 /* Move the gap to array position POS. Parallel to move_gap() in |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
671 insdel.c but somewhat simplified. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
672 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
673 static void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
674 gap_array_move_gap (Gap_Array *ga, Elemcount pos) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
675 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
676 Elemcount gap = ga->gap; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
677 Elemcount gapsize = ga->gapsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
678 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
679 if (pos < gap) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
680 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
681 memmove (GAP_ARRAY_MEMEL_ADDR (ga, pos + gapsize), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
682 GAP_ARRAY_MEMEL_ADDR (ga, pos), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
683 (gap - pos)*ga->elsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
684 gap_array_adjust_markers (ga, (Memxpos) pos, (Memxpos) gap, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
685 gapsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
686 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
687 else if (pos > gap) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
688 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
689 memmove (GAP_ARRAY_MEMEL_ADDR (ga, gap), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
690 GAP_ARRAY_MEMEL_ADDR (ga, gap + gapsize), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
691 (pos - gap)*ga->elsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
692 gap_array_adjust_markers (ga, (Memxpos) (gap + gapsize), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
693 (Memxpos) (pos + gapsize), - gapsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
694 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
695 ga->gap = pos; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
696 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
697 gap_array_recompute_derived_values (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
698 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
699 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
700 /* Make the gap INCREMENT characters longer. Parallel to make_gap() in |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
701 insdel.c. The gap array may be moved, so assign the return value back |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
702 to the array pointer. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
703 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
704 static Gap_Array * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
705 gap_array_make_gap (Gap_Array *ga, Elemcount increment) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
706 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
707 Elemcount real_gap_loc; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
708 Elemcount old_gap_size; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
709 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
710 /* If we have to get more space, get enough to last a while. We use |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
711 a geometric progression that saves on realloc space. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
712 increment += 100 + ga->numels / 8; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
713 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
714 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
715 if (ga->is_lisp) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
716 ga = (Gap_Array *) mc_realloc (ga, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
717 offsetof (Gap_Array, array) + |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
718 (ga->numels + ga->gapsize + increment) * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
719 ga->elsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
720 else |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
721 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
722 ga = (Gap_Array *) xrealloc (ga, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
723 offsetof (Gap_Array, array) + |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
724 (ga->numels + ga->gapsize + increment) * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
725 ga->elsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
726 if (ga == 0) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
727 memory_full (); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
728 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
729 real_gap_loc = ga->gap; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
730 old_gap_size = ga->gapsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
731 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
732 /* Call the newly allocated space a gap at the end of the whole space. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
733 ga->gap = ga->numels + ga->gapsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
734 ga->gapsize = increment; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
735 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
736 /* Move the new gap down to be consecutive with the end of the old one. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
737 This adjusts the markers properly too. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
738 gap_array_move_gap (ga, real_gap_loc + old_gap_size); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
739 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
740 /* Now combine the two into one large gap. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
741 ga->gapsize += old_gap_size; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
742 ga->gap = real_gap_loc; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
743 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
744 gap_array_recompute_derived_values (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
745 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
746 return ga; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
747 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
748 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
749 /* ------------------------------- */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
750 /* external functions */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
751 /* ------------------------------- */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
752 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
753 Bytecount |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
754 gap_array_byte_size (Gap_Array *ga) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
755 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
756 return offsetof (Gap_Array, array) + (ga->numels + ga->gapsize) * ga->elsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
757 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
758 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
759 /* Insert NUMELS elements (pointed to by ELPTR) into the specified |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
760 gap array at POS. The gap array may be moved, so assign the |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
761 return value back to the array pointer. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
762 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
763 Gap_Array * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
764 gap_array_insert_els (Gap_Array *ga, Elemcount pos, void *elptr, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
765 Elemcount numels) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
766 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
767 assert (pos >= 0 && pos <= ga->numels); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
768 if (ga->gapsize < numels) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
769 ga = gap_array_make_gap (ga, numels - ga->gapsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
770 if (pos != ga->gap) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
771 gap_array_move_gap (ga, pos); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
772 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
773 memcpy (GAP_ARRAY_MEMEL_ADDR (ga, ga->gap), (char *) elptr, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
774 numels*ga->elsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
775 ga->gapsize -= numels; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
776 ga->gap += numels; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
777 ga->numels += numels; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
778 gap_array_recompute_derived_values (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
779 /* This is the equivalent of insert-before-markers. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
780 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
781 #### Should only happen if marker is "moves forward at insert" type. |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
782 */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
783 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
784 gap_array_adjust_markers (ga, pos - 1, pos, numels); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
785 return ga; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
786 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
787 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
788 /* Delete NUMELS elements from the specified gap array, starting at FROM. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
789 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
790 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
791 gap_array_delete_els (Gap_Array *ga, Elemcount from, Elemcount numdel) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
792 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
793 Elemcount to = from + numdel; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
794 Elemcount gapsize = ga->gapsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
795 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
796 assert (from >= 0); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
797 assert (numdel >= 0); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
798 assert (to <= ga->numels); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
799 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
800 /* Make sure the gap is somewhere in or next to what we are deleting. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
801 if (to < ga->gap) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
802 gap_array_move_gap (ga, to); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
803 if (from > ga->gap) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
804 gap_array_move_gap (ga, from); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
805 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
806 /* Relocate all markers pointing into the new, larger gap |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
807 to point at the end of the text before the gap. */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
808 gap_array_adjust_markers (ga, to + gapsize, to + gapsize, |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
809 - numdel - gapsize); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
810 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
811 ga->gapsize += numdel; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
812 ga->numels -= numdel; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
813 ga->gap = from; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
814 gap_array_recompute_derived_values (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
815 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
816 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
817 Gap_Array_Marker * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
818 gap_array_make_marker (Gap_Array *ga, Elemcount pos) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
819 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
820 Gap_Array_Marker *m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
821 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
822 assert (pos >= 0 && pos <= ga->numels); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
823 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
824 m = XGAP_ARRAY_MARKER (ALLOC_NORMAL_LISP_OBJECT (gap_array_marker)); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
825 #else /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
826 if (gap_array_marker_freelist) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
827 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
828 m = gap_array_marker_freelist; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
829 gap_array_marker_freelist = gap_array_marker_freelist->next; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
830 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
831 else |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
832 m = xnew (Gap_Array_Marker); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
833 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
834 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
835 m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
836 m->next = ga->markers; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
837 ga->markers = m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
838 return m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
839 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
840 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
841 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
842 gap_array_delete_marker (Gap_Array *ga, Gap_Array_Marker *m) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
843 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
844 Gap_Array_Marker *p, *prev; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
845 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
846 for (prev = 0, p = ga->markers; p && p != m; prev = p, p = p->next) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
847 ; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
848 assert (p); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
849 if (prev) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
850 prev->next = p->next; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
851 else |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
852 ga->markers = p->next; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
853 #ifndef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
854 m->next = gap_array_marker_freelist; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
855 m->pos = 0xDEADBEEF; /* -559038737 base 10 */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
856 gap_array_marker_freelist = m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
857 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
858 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
859 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
860 #ifndef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
861 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
862 gap_array_delete_all_markers (Gap_Array *ga) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
863 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
864 Gap_Array_Marker *p, *next; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
865 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
866 for (p = ga->markers; p; p = next) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
867 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
868 next = p->next; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
869 p->next = gap_array_marker_freelist; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
870 p->pos = 0xDEADBEEF; /* -559038737 as an int */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
871 gap_array_marker_freelist = p; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
872 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
873 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
874 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
875 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
876 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
877 gap_array_move_marker (Gap_Array *ga, Gap_Array_Marker *m, Elemcount pos) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
878 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
879 assert (pos >= 0 && pos <= ga->numels); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
880 m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
881 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
882 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
883 Gap_Array * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
884 make_gap_array (Elemcount elsize, int USED_IF_NEW_GC (do_lisp)) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
885 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
886 Gap_Array *ga; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
887 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
888 /* #### I don't quite understand why it's necessary to make all these |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
889 internal objects into Lisp objects under NEW_GC. It's a pain in the |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
890 ass to code around this. I'm proceeding on the assumption that it's |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
891 not really necessary to do it after all, and so we only make a Lisp- |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
892 object gap array when the object being held is a Lisp_Object, i.e. a |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
893 pointer to a Lisp object. In the case where instead we hold a `struct |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
894 range_table_entry', just blow it off. Otherwise we either need to do |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
895 a bunch of painful and/or boring rewriting. --ben */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
896 if (do_lisp) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
897 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
898 ga = XGAP_ARRAY (ALLOC_SIZED_LISP_OBJECT (sizeof (Gap_Array), |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
899 gap_array)); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
900 ga->is_lisp = 1; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
901 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
902 else |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
903 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
904 ga = xnew_and_zero (Gap_Array); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
905 ga->elsize = elsize; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
906 return ga; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
907 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
908 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
909 Gap_Array * |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
910 gap_array_clone (Gap_Array *ga) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
911 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
912 Bytecount size = gap_array_byte_size (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
913 Gap_Array *ga2; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
914 Gap_Array_Marker *m; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
915 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
916 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
917 if (ga->is_lisp) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
918 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
919 ga2 = XGAP_ARRAY (ALLOC_SIZED_LISP_OBJECT (size, gap_array)); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
920 copy_lisp_object (wrap_gap_array (ga2), wrap_gap_array (ga)); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
921 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
922 else |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
923 #endif |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
924 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
925 ga2 = (Gap_Array *) xmalloc (size); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
926 memcpy (ga2, ga, size); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
927 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
928 ga2->markers = NULL; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
929 for (m = ga->markers; m; m = m->next) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
930 gap_array_make_marker (ga2, m->pos); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
931 return ga2; |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
932 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
933 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
934 #ifndef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
935 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
936 free_gap_array (Gap_Array *ga) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
937 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
938 gap_array_delete_all_markers (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
939 xfree (ga); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
940 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
941 #endif /* not NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
942 |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
943 #ifdef MEMORY_USAGE_STATS |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
944 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
945 /* Return memory usage for gap array GA. The returned value is the total |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
946 amount of bytes actually being used for the gap array, including all |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
947 overhead. The extra amount of space in the gap array that is used |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
948 for the gap is counted in GAP_OVERHEAD, not in WAS_REQUESTED. |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
949 If NEW_GC, space for gap-array markers is returned through MARKER_ANCILLARY; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
950 otherwise it's added into the gap array usage. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
951 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
952 Bytecount |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
953 gap_array_memory_usage (Gap_Array *ga, struct usage_stats *stats, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
954 Bytecount *marker_ancillary) |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
955 { |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
956 Bytecount total = 0; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
957 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
958 /* We have to be a bit tricky here because not all of the |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
959 memory that malloc() will claim as "requested" was actually |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
960 requested -- some of it makes up the gap. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
961 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
962 Bytecount size = gap_array_byte_size (ga); |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
963 Bytecount gap_size = ga->gapsize * ga->elsize; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
964 Bytecount malloc_used = malloced_storage_size (ga, size, 0); |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
965 total += malloc_used; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
966 stats->was_requested += size - gap_size; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
967 stats->gap_overhead += gap_size; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
968 stats->malloc_overhead += malloc_used - size; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
969 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
970 #ifdef NEW_GC |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
971 { |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
972 Bytecount marker_usage = 0; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
973 Gap_Array_Marker *p; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
974 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
975 for (p = ga->markers; p; p = p->next) |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
976 marker_usage += lisp_object_memory_usage (wrap_gap_array_marker (p)); |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
977 if (marker_ancillary) |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
978 *marker_ancillary = marker_usage; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
979 } |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
980 #else |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
981 { |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
982 Gap_Array_Marker *p; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
983 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
984 for (p = ga->markers; p; p = p->next) |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
985 total += malloced_storage_size (p, sizeof (p), stats); |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
986 if (marker_ancillary) |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
987 *marker_ancillary = 0; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
988 } |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
989 #endif /* (not) NEW_GC */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
990 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
991 return total; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
992 } |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
993 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
994 #endif /* MEMORY_USAGE_STATS */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
995 |
5168
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
996 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
997 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
998 /* Initialization */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
999 /*****************************************************************************/ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1000 |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1001 void |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1002 syms_of_array (void) |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1003 { |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1004 #ifdef NEW_GC |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1005 INIT_LISP_OBJECT (gap_array_marker); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1006 INIT_LISP_OBJECT (gap_array); |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1007 #endif /* NEW_GC */ |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1008 } |
cf900a2f1fa3
extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1009 |