aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5c7ce31cad8..714827f6ae3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2226,6 +2226,32 @@ make_string (const char *contents, ptrdiff_t nbytes)
2226 return val; 2226 return val;
2227} 2227}
2228 2228
2229#ifdef USE_LOCAL_ALLOCATORS
2230
2231/* Initialize the string S from DATA and SIZE. S must be followed by
2232 SIZE + 1 bytes of memory that can be used. Return S tagged as a
2233 Lisp object. */
2234
2235Lisp_Object
2236local_string_init (struct Lisp_String *s, char const *data, ptrdiff_t size)
2237{
2238 unsigned char *data_copy = (unsigned char *) (s + 1);
2239 parse_str_as_multibyte ((unsigned char const *) data,
2240 size, &s->size, &s->size_byte);
2241 if (size == s->size || size != s->size_byte)
2242 {
2243 s->size = size;
2244 s->size_byte = -1;
2245 }
2246 s->intervals = NULL;
2247 s->data = data_copy;
2248 memcpy (data_copy, data, size);
2249 data_copy[size] = '\0';
2250 return make_lisp_ptr (s, Lisp_String);
2251}
2252
2253#endif
2254
2229 2255
2230/* Make an unibyte string from LENGTH bytes at CONTENTS. */ 2256/* Make an unibyte string from LENGTH bytes at CONTENTS. */
2231 2257
@@ -3288,6 +3314,22 @@ See also the function `vector'. */)
3288 return vector; 3314 return vector;
3289} 3315}
3290 3316
3317#ifdef USE_LOCAL_ALLOCATORS
3318
3319/* Initialize V with LENGTH objects each with value INIT,
3320 and return it tagged as a Lisp Object. */
3321
3322INLINE Lisp_Object
3323local_vector_init (struct Lisp_Vector *v, ptrdiff_t length, Lisp_Object init)
3324{
3325 v->header.size = length;
3326 for (ptrdiff_t i = 0; i < length; i++)
3327 v->contents[i] = init;
3328 return make_lisp_ptr (v, Lisp_Vectorlike);
3329}
3330
3331#endif
3332
3291 3333
3292DEFUN ("vector", Fvector, Svector, 0, MANY, 0, 3334DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
3293 doc: /* Return a newly created vector with specified arguments as elements. 3335 doc: /* Return a newly created vector with specified arguments as elements.