Coverage Report

Created: 2025-11-16 07:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/psi/zgeneric.c
Line
Count
Source
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* Array/string/dictionary generic operators for PostScript */
18
#include "memory_.h"
19
#include "ghost.h"
20
#include "gsstruct.h"   /* for st_bytes */
21
#include "oper.h"
22
#include "dstack.h"   /* for systemdict */
23
#include "estack.h"   /* for forall */
24
#include "iddict.h"
25
#include "iname.h"
26
#include "ipacked.h"
27
#include "ivmspace.h"
28
#include "store.h"
29
30
/* This file implements copy, get, put, getinterval, putinterval, */
31
/* length, and forall, which apply generically to */
32
/* arrays, strings, and dictionaries.  (Copy also has a special */
33
/* meaning for copying the top N elements of the stack.) */
34
35
/* See the comment in opdef.h for an invariant which allows */
36
/* more efficient implementation of forall. */
37
38
/* Forward references */
39
static int zcopy_integer(i_ctx_t *);
40
static int zcopy_interval(i_ctx_t *);
41
static int copy_interval(i_ctx_t *, os_ptr, uint, os_ptr, client_name_t);
42
43
/* <various1> <various2> copy <various> */
44
/* <obj1> ... <objn> <int> copy <obj1> ... <objn> <obj1> ... <objn> */
45
/* Note that this implements copy for arrays and strings, */
46
/* but not for dictionaries (see zcopy_dict in zdict.c). */
47
int
48
zcopy(i_ctx_t *i_ctx_p)
49
1.08G
{
50
1.08G
    os_ptr op = osp;
51
1.08G
    int type;
52
1.08G
    check_op(1);
53
1.08G
    type = r_type(op);
54
1.08G
    if (type == t_integer)
55
1.01G
        return zcopy_integer(i_ctx_p);
56
62.0M
    check_op(2);
57
62.0M
    switch (type) {
58
25.6M
        case t_array:
59
59.3M
        case t_string:
60
59.3M
            return zcopy_interval(i_ctx_p);
61
2.69M
        case t_dictionary:
62
2.69M
            return zcopy_dict(i_ctx_p);
63
13
        default:
64
13
            return_op_typecheck(op);
65
62.0M
    }
66
62.0M
}
67
68
/* <obj1> ... <objn> <int> copy <obj1> ... <objn> <obj1> ... <objn> */
69
static int
70
zcopy_integer(i_ctx_t *i_ctx_p)
71
1.01G
{
72
1.01G
    os_ptr op = osp;
73
1.01G
    os_ptr op1 = op - 1;
74
1.01G
    int count, i;
75
1.01G
    int code;
76
77
1.01G
    if ((uint) op->value.intval > (uint)(op - osbot)) {
78
        /* There might be enough elements in other blocks. */
79
69
        check_type(*op, t_integer);
80
69
        if (op->value.intval >= (int)ref_stack_count(&o_stack))
81
13
            return_error(gs_error_stackunderflow);
82
56
        if (op->value.intval < 0)
83
55
            return_error(gs_error_rangecheck);
84
56
        check_int_ltu(*op, ref_stack_count(&o_stack));
85
1
        count = op->value.intval;
86
1.01G
    } else if (op1 + (count = op->value.intval) <= ostop) {
87
        /* Fast case. */
88
1.01G
        memcpy((char *)op, (char *)(op - count), count * sizeof(ref));
89
1.01G
        push(count - 1);
90
1.01G
        return 0;
91
1.01G
    }
92
    /* Do it the slow, general way. */
93
53
    code = ref_stack_push(&o_stack, count - 1);
94
53
    if (code < 0)
95
0
        return code;
96
1.59k
    for (i = 0; i < count; i++) {
97
1.54k
        ref *o = ref_stack_index(&o_stack, i);
98
1.54k
        ref *o1 = ref_stack_index(&o_stack, i + count);
99
100
1.54k
        if (o == NULL || o1 == NULL)
101
0
            return_error(gs_error_stackunderflow);
102
1.54k
        *o = *o1;
103
1.54k
    }
104
53
    return 0;
105
53
}
106
107
/* <array1> <array2> copy <subarray2> */
108
/* <string1> <string2> copy <substring2> */
109
static int
110
zcopy_interval(i_ctx_t *i_ctx_p)
111
59.3M
{
112
59.3M
    os_ptr op = osp;
113
59.3M
    os_ptr op1 = op - 1;
114
59.3M
    int code = copy_interval(i_ctx_p, op, 0, op1, "copy");
115
116
59.3M
    if (code < 0)
117
5
        return code;
118
59.3M
    r_set_size(op, r_size(op1));
119
59.3M
    *op1 = *op;
120
59.3M
    pop(1);
121
59.3M
    return 0;
122
59.3M
}
123
124
/* <array|dict|name|packedarray|string> length <int> */
125
static int
126
zlength(i_ctx_t *i_ctx_p)
127
601M
{
128
601M
    os_ptr op = osp;
129
130
601M
    check_op(1);
131
601M
    switch (r_type(op)) {
132
62.2M
        case t_array:
133
449M
        case t_string:
134
451M
        case t_mixedarray:
135
454M
        case t_shortarray:
136
454M
            check_read(*op);
137
454M
            make_int(op, r_size(op));
138
454M
            return 0;
139
144M
        case t_dictionary:
140
144M
            check_dict_read(*op);
141
144M
            make_int(op, dict_length(op));
142
144M
            return 0;
143
2.74M
        case t_name: {
144
2.74M
            ref str;
145
146
2.74M
            name_string_ref(imemory, op, &str);
147
2.74M
            make_int(op, r_size(&str));
148
2.74M
            return 0;
149
144M
        }
150
4
        case t_astruct:
151
4
            if (gs_object_type(imemory, op->value.pstruct) != &st_bytes)
152
4
                return_error(gs_error_typecheck);
153
0
            check_read(*op);
154
0
            make_int(op, gs_object_size(imemory, op->value.pstruct));
155
0
            return 0;
156
22
        default:
157
22
            return_op_typecheck(op);
158
601M
    }
159
601M
}
160
161
/* <array|packedarray|string> <index> get <obj> */
162
/* <dict> <key> get <obj> */
163
static int
164
zget(i_ctx_t *i_ctx_p)
165
2.22G
{
166
2.22G
    int code;
167
2.22G
    os_ptr op = osp;
168
2.22G
    os_ptr op1 = op - 1;
169
2.22G
    ref *pvalue;
170
171
2.22G
    check_op(2);
172
173
2.22G
    switch (r_type(op1)) {
174
459M
        case t_dictionary:
175
459M
            check_dict_read(*op1);
176
459M
            if (dict_find(op1, op, &pvalue) <= 0)
177
36
                return_error(gs_error_undefined);
178
459M
            op[-1] = *pvalue;
179
459M
            break;
180
516M
        case t_string:
181
516M
            check_read(*op1);
182
516M
            check_int_ltu(*op, r_size(op1));
183
516M
            make_int(op1, op1->value.bytes[(uint) op->value.intval]);
184
516M
            break;
185
1.14G
        case t_array:
186
1.19G
        case t_mixedarray:
187
1.24G
        case t_shortarray:
188
1.24G
            check_type(*op, t_integer);
189
1.24G
            check_read(*op1);
190
1.24G
            code = array_get(imemory, op1, op->value.intval, op1);
191
1.24G
            if (code < 0)
192
4
                return code;
193
1.24G
            break;
194
1.24G
        case t__invalid:
195
0
            return_error(gs_error_stackunderflow);
196
23
        default:
197
23
            return_error(gs_error_typecheck);
198
2.22G
    }
199
2.22G
    pop(1);
200
2.22G
    return 0;
201
2.22G
}
202
203
/* <array> <index> <obj> put - */
204
/* <dict> <key> <value> put - */
205
/* <string> <index> <int> put - */
206
static int
207
zput(i_ctx_t *i_ctx_p)
208
1.41G
{
209
1.41G
    os_ptr op = osp;
210
1.41G
    os_ptr op1 = op - 1;
211
1.41G
    os_ptr op2 = op1 - 1;
212
1.41G
    byte *sdata;
213
1.41G
    uint ssize;
214
215
1.41G
    check_op(3);
216
1.41G
    switch (r_type(op2)) {
217
1.10G
        case t_dictionary:
218
1.10G
            check_dict_write(*op2);
219
1.10G
            {
220
1.10G
                int code = idict_put(op2, op1, op);
221
222
1.10G
                if (code < 0)
223
0
                    return code; /* error */
224
1.10G
            }
225
1.10G
            break;
226
1.10G
        case t_array:
227
93.5M
            check_write(*op2);
228
93.5M
            check_int_ltu(*op1, r_size(op2));
229
93.5M
            store_check_dest(op2, op);
230
93.5M
            {
231
93.5M
                ref *eltp = op2->value.refs + (uint) op1->value.intval;
232
233
93.5M
                ref_assign_old(op2, eltp, op, "put");
234
93.5M
            }
235
93.5M
            break;
236
0
        case t_mixedarray:  /* packed arrays are read-only */
237
0
        case t_shortarray:
238
0
            return_error(gs_error_invalidaccess);
239
222M
        case t_string:
240
222M
            sdata = op2->value.bytes;
241
222M
            ssize = r_size(op2);
242
222M
str:      check_write(*op2);
243
222M
            check_int_ltu(*op1, ssize);
244
222M
            check_int_leu(*op, 0xff);
245
222M
            sdata[(uint)op1->value.intval] = (byte)op->value.intval;
246
222M
            break;
247
1
        case t_astruct:
248
1
            if (gs_object_type(imemory, op2->value.pstruct) != &st_bytes)
249
1
                return_error(gs_error_typecheck);
250
0
            sdata = r_ptr(op2, byte);
251
0
            ssize = gs_object_size(imemory, op2->value.pstruct);
252
0
            goto str;
253
19
        default:
254
19
            return_op_typecheck(op2);
255
1.41G
    }
256
1.41G
    pop(3);
257
1.41G
    return 0;
258
1.41G
}
259
260
/* <array> <index> <obj> .forceput - */
261
/* <dict> <key> <value> .forceput - */
262
/*
263
 * This forces a "put" even if the object is not writable, and (if the
264
 * object is systemdict or the save level is 0) even if the value is in
265
 * local VM.  It is meant to be used only for replacing the value of
266
 * FontDirectory in systemdict when switching between local and global VM,
267
 * and a few similar applications.  After initialization, this operator
268
 * should no longer be accessible by name.
269
 */
270
static int
271
zforceput(i_ctx_t *i_ctx_p)
272
90.1M
{
273
90.1M
    os_ptr op = osp;
274
90.1M
    os_ptr op1 = op - 1;
275
90.1M
    os_ptr op2 = op - 2;
276
90.1M
    int code;
277
278
90.1M
    check_op(3);
279
280
90.1M
    switch (r_type(op2)) {
281
192k
    case t_array:
282
192k
        check_int_ltu(*op1, r_size(op2));
283
192k
        if (r_space(op2) > r_space(op)) {
284
0
            if (imemory_save_level(iimemory))
285
0
                return_error(gs_error_invalidaccess);
286
0
        }
287
192k
        {
288
192k
            ref *eltp = op2->value.refs + (uint) op1->value.intval;
289
290
192k
            ref_assign_old(op2, eltp, op, "put");
291
192k
        }
292
192k
        break;
293
89.9M
    case t_dictionary:
294
89.9M
        if (op2->value.pdict == systemdict->value.pdict ||
295
18.0M
            !imemory_save_level(iimemory)
296
89.9M
            ) {
297
86.3M
            uint space = r_space(op2);
298
299
86.3M
            r_set_space(op2, avm_local);
300
86.3M
            code = idict_put(op2, op1, op);
301
86.3M
            r_set_space(op2, space);
302
86.3M
        } else
303
3.60M
            code = idict_put(op2, op1, op);
304
89.9M
        if (code < 0)
305
8
            return code;
306
89.9M
        break;
307
89.9M
    default:
308
0
        return_error(gs_error_typecheck);
309
90.1M
    }
310
90.1M
    pop(3);
311
90.1M
    return 0;
312
90.1M
}
313
314
/* <seq:array|packedarray|string> <index> <count> getinterval <subseq> */
315
static int
316
zgetinterval(i_ctx_t *i_ctx_p)
317
82.9M
{
318
82.9M
    os_ptr op = osp;
319
82.9M
    os_ptr op1 = op - 1;
320
82.9M
    os_ptr op2 = op1 - 1;
321
82.9M
    uint index;
322
82.9M
    uint count;
323
324
82.9M
    check_op(3);
325
326
82.9M
    switch (r_type(op2)) {
327
9
        default:
328
9
            return_op_typecheck(op2);
329
4.85M
        case t_array:
330
53.2M
        case t_string:
331
82.9M
        case t_mixedarray:
332
82.9M
        case t_shortarray:;
333
82.9M
    }
334
82.9M
    check_read(*op2);
335
82.9M
    check_int_leu(*op1, r_size(op2));
336
82.9M
    index = op1->value.intval;
337
82.9M
    check_int_leu(*op, r_size(op2) - index);
338
82.9M
    count = op->value.intval;
339
82.9M
    switch (r_type(op2)) {
340
4.85M
        case t_array:
341
4.85M
            op2->value.refs += index;
342
4.85M
            break;
343
48.3M
        case t_string:
344
48.3M
            op2->value.bytes += index;
345
48.3M
            break;
346
29.6M
        case t_mixedarray: {
347
29.6M
            const ref_packed *packed = op2->value.packed;
348
349
235M
            for (; index--;)
350
205M
                packed = packed_next(packed);
351
29.6M
            op2->value.packed = packed;
352
29.6M
            break;
353
0
        }
354
0
        case t_shortarray:
355
0
            op2->value.packed += index;
356
0
            break;
357
82.9M
    }
358
82.9M
    r_set_size(op2, count);
359
82.9M
    pop(2);
360
82.9M
    return 0;
361
82.9M
}
362
363
/* <array1> <index> <array2|packedarray2> putinterval - */
364
/* <string1> <index> <string2> putinterval - */
365
/* <bytestring1> <index> <string2> putinterval - */
366
static int
367
zputinterval(i_ctx_t *i_ctx_p)
368
26.3M
{
369
26.3M
    os_ptr op = osp;
370
26.3M
    os_ptr opindex = op - 1;
371
26.3M
    os_ptr opto = opindex - 1;
372
26.3M
    int code;
373
374
26.3M
    check_op(3);
375
376
26.3M
    switch (r_type(opto)) {
377
8
        default:
378
8
            return_error(gs_error_typecheck);
379
0
        case t__invalid:
380
0
            if (r_type(op) != t_array && r_type(op) != t_string && r_type(op) != t__invalid)
381
0
                return_error(gs_error_typecheck); /* to match Distiller */
382
0
            else
383
0
                return_error(gs_error_stackunderflow);
384
0
        case t_mixedarray:
385
0
        case t_shortarray:
386
0
            return_error(gs_error_invalidaccess);
387
3.44M
        case t_array:
388
26.3M
        case t_string:
389
26.3M
            check_write(*opto);
390
26.3M
            check_int_leu(*opindex, r_size(opto));
391
26.3M
            code = copy_interval(i_ctx_p, opto, (uint)(opindex->value.intval),
392
26.3M
                                 op, "putinterval");
393
26.3M
            break;
394
0
        case t_astruct: {
395
0
            uint dsize, ssize, index;
396
397
0
            check_write(*opto);
398
0
            if (gs_object_type(imemory, opto->value.pstruct) != &st_bytes)
399
0
                return_error(gs_error_typecheck);
400
0
            dsize = gs_object_size(imemory, opto->value.pstruct);
401
0
            check_int_leu(*opindex, dsize);
402
0
            index = (uint)opindex->value.intval;
403
0
            check_read_type(*op, t_string);
404
0
            ssize = r_size(op);
405
0
            if (ssize > dsize - index)
406
0
                return_error(gs_error_rangecheck);
407
0
            memcpy(r_ptr(opto, byte) + index, op->value.const_bytes, ssize);
408
0
            code = 0;
409
0
            break;
410
0
        }
411
26.3M
    }
412
26.3M
    if (code >= 0)
413
26.3M
        pop(3);
414
26.3M
    return code;
415
26.3M
}
416
417
/* <array|packedarray|string> <<element> proc> forall - */
418
/* <dict> <<key> <value> proc> forall - */
419
static int
420
    array_continue(i_ctx_t *),
421
    dict_continue(i_ctx_t *),
422
    string_continue(i_ctx_t *),
423
    packedarray_continue(i_ctx_t *);
424
static int forall_cleanup(i_ctx_t *);
425
static int
426
zforall(i_ctx_t *i_ctx_p)
427
81.9M
{
428
81.9M
    os_ptr op = osp;
429
81.9M
    os_ptr obj = op - 1;
430
81.9M
    es_ptr ep;
431
81.9M
    es_ptr cproc;
432
433
81.9M
    check_estack(6);
434
    /* check_estack() could cause the exec stack to be copied to a new block
435
     * so don't caulculate ep and things based on ep until *after* the check
436
     */
437
81.9M
    ep = esp;
438
81.9M
    cproc = ep + 4;
439
81.9M
    check_proc(*op);
440
81.9M
    switch (r_type(obj)) {
441
20
        default:
442
20
            return_op_typecheck(obj);
443
27.6M
        case t_array:
444
27.6M
            check_read(*obj);
445
27.6M
            make_op_estack(cproc, array_continue);
446
27.6M
            break;
447
42.6M
        case t_dictionary:
448
42.6M
            check_dict_read(*obj);
449
42.6M
            make_int(cproc, dict_first(obj));
450
42.6M
            ++cproc;
451
42.6M
            make_op_estack(cproc, dict_continue);
452
42.6M
            break;
453
192k
        case t_string:
454
192k
            check_read(*obj);
455
192k
            make_op_estack(cproc, string_continue);
456
192k
            break;
457
8.71M
        case t_mixedarray:
458
11.3M
        case t_shortarray:
459
11.3M
            check_read(*obj);
460
11.3M
            make_op_estack(cproc, packedarray_continue);
461
11.3M
            break;
462
81.9M
    }
463
    /*
464
     * Push:
465
     *   - a mark;
466
     *   - the composite object;
467
     *   - the procedure;
468
     *   - the iteration index (only for dictionaries, done above);
469
     * and invoke the continuation operator.
470
     */
471
81.9M
    make_mark_estack(ep + 1, es_for, forall_cleanup);
472
81.9M
    ep[2] = *obj;
473
81.9M
    ep[3] = *op;
474
81.9M
    esp = cproc - 1;
475
81.9M
    ref_stack_pop(&o_stack, 2);
476
81.9M
    return (*real_opproc(cproc))(i_ctx_p);
477
81.9M
}
478
/* Continuation operator for arrays */
479
static int
480
array_continue(i_ctx_t *i_ctx_p)
481
288M
{
482
288M
    os_ptr op = osp;
483
288M
    es_ptr obj = esp - 1;
484
485
288M
    if (r_size(obj)) {   /* continue */
486
261M
        push(1);
487
261M
        r_dec_size(obj, 1);
488
261M
        *op = *obj->value.refs;
489
261M
        obj->value.refs++;
490
261M
        esp += 2;
491
261M
        *esp = obj[1];
492
261M
        return o_push_estack;
493
261M
    } else {     /* done */
494
27.4M
        esp -= 3;    /* pop mark, object, proc */
495
27.4M
        return o_pop_estack;
496
27.4M
    }
497
288M
}
498
/* Continuation operator for dictionaries */
499
static int
500
dict_continue(i_ctx_t *i_ctx_p)
501
1.83G
{
502
1.83G
    os_ptr op = osp;
503
1.83G
    es_ptr obj = esp - 2;
504
1.83G
    int index = esp->value.intval;
505
506
1.83G
    if (r_type(obj) != t_dictionary)
507
0
        return_error(gs_error_typecheck);
508
509
1.83G
    push(2);     /* make room for key and value */
510
1.83G
    if ((index = dict_next(obj, index, op - 1)) >= 0) { /* continue */
511
1.79G
        esp->value.intval = index;
512
1.79G
        esp += 2;
513
1.79G
        *esp = obj[1];
514
1.79G
        return o_push_estack;
515
1.79G
    } else {     /* done */
516
42.0M
        pop(2);      /* undo push */
517
42.0M
        esp -= 4;    /* pop mark, object, proc, index */
518
42.0M
        return o_pop_estack;
519
42.0M
    }
520
1.83G
}
521
/* Continuation operator for strings */
522
static int
523
string_continue(i_ctx_t *i_ctx_p)
524
192k
{
525
192k
    os_ptr op = osp;
526
192k
    es_ptr obj = esp - 1;
527
528
192k
    if (r_size(obj)) {   /* continue */
529
180
        push(1);    /* check for result space on stack BEFORE changing string size */
530
180
        r_dec_size(obj, 1); /* Bug 701550 :-O */
531
180
        make_int(op, *obj->value.bytes);
532
180
        obj->value.bytes++;
533
180
        esp += 2;
534
180
        *esp = obj[1];
535
180
        return o_push_estack;
536
192k
    } else {     /* done */
537
192k
        esp -= 3;    /* pop mark, object, proc */
538
192k
        return o_pop_estack;
539
192k
    }
540
192k
}
541
/* Continuation operator for packed arrays */
542
static int
543
packedarray_continue(i_ctx_t *i_ctx_p)
544
58.4M
{
545
58.4M
    os_ptr op = osp;
546
58.4M
    es_ptr obj = esp - 1;
547
548
58.4M
    if (r_size(obj)) {   /* continue */
549
47.0M
        const ref_packed *packed = obj->value.packed;
550
551
47.0M
        r_dec_size(obj, 1);
552
47.0M
        push(1);
553
47.0M
        packed_get(imemory, packed, op);
554
47.0M
        obj->value.packed = packed_next(packed);
555
47.0M
        esp += 2;
556
47.0M
        *esp = obj[1];
557
47.0M
        return o_push_estack;
558
47.0M
    } else {     /* done */
559
11.3M
        esp -= 3;    /* pop mark, object, proc */
560
11.3M
        return o_pop_estack;
561
11.3M
    }
562
58.4M
}
563
/* Vacuous cleanup procedure */
564
static int
565
forall_cleanup(i_ctx_t *i_ctx_p)
566
787k
{
567
787k
    return 0;
568
787k
}
569
570
/* ------ Initialization procedure ------ */
571
572
const op_def zgeneric_op_defs[] =
573
{
574
    {"1copy", zcopy},
575
    {"2forall", zforall},
576
    {"3.forceput", zforceput},
577
    {"2get", zget},
578
    {"3getinterval", zgetinterval},
579
    {"1length", zlength},
580
    {"3put", zput},
581
    {"3putinterval", zputinterval},
582
                /* Internal operators */
583
    {"0%array_continue", array_continue},
584
    {"0%dict_continue", dict_continue},
585
    {"0%packedarray_continue", packedarray_continue},
586
    {"0%string_continue", string_continue},
587
    op_def_end(0)
588
};
589
590
/* ------ Shared routines ------ */
591
592
/* Copy an interval from one operand to another. */
593
/* This is used by both putinterval and string/array copy. */
594
/* The destination is known to be an array or string, */
595
/* and the starting index is known to be less than or equal to */
596
/* its length; nothing else has been checked. */
597
static int
598
copy_interval(i_ctx_t *i_ctx_p /* for ref_assign_old */, os_ptr prto,
599
              uint index, os_ptr prfrom, client_name_t cname)
600
85.7M
{
601
85.7M
    int fromtype = r_type(prfrom);
602
85.7M
    uint fromsize = r_size(prfrom);
603
604
85.7M
    if (!(fromtype == r_type(prto) ||
605
192k
          ((fromtype == t_shortarray || fromtype == t_mixedarray) &&
606
192k
           r_type(prto) == t_array))
607
85.7M
        )
608
85.7M
        return_op_typecheck(prfrom);
609
85.7M
    check_read(*prfrom);
610
85.7M
    check_write(*prto);
611
85.7M
    if (fromsize > r_size(prto) - index)
612
0
        return_error(gs_error_rangecheck);
613
85.7M
    switch (fromtype) {
614
28.8M
        case t_array:
615
28.8M
            {     /* We have to worry about aliasing, */
616
                /* but refcpy_to_old takes care of it for us. */
617
28.8M
                return refcpy_to_old(prto, index, prfrom->value.refs,
618
28.8M
                                     fromsize, idmemory, cname);
619
0
            }
620
56.6M
        case t_string:
621
56.6M
            { /* memmove takes care of aliasing. */
622
56.6M
                memmove(prto->value.bytes + index, prfrom->value.bytes,
623
56.6M
                        fromsize);
624
56.6M
            }
625
56.6M
            break;
626
192k
        case t_mixedarray:
627
192k
        case t_shortarray:
628
192k
            { /* We don't have to worry about aliasing, because */
629
                /* packed arrays are read-only and hence the destination */
630
                /* can't be a packed array. */
631
192k
                uint i;
632
192k
                const ref_packed *packed = prfrom->value.packed;
633
192k
                ref *pdest = prto->value.refs + index;
634
192k
                ref elt;
635
636
49.5M
                for (i = 0; i < fromsize; i++, pdest++) {
637
49.3M
                    packed_get(imemory, packed, &elt);
638
49.3M
                    ref_assign_old(prto, pdest, &elt, cname);
639
49.3M
                    packed = packed_next(packed);
640
49.3M
                }
641
192k
            }
642
192k
            break;
643
85.7M
    }
644
56.8M
    return 0;
645
85.7M
}