MCPcopy Create free account
hub / github.com/Kode/Kha / hl_alloc_array

Function hl_alloc_array

Backends/Kore-HL/hl/src/std/array.c:24–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include <hl.h>
23
24HL_PRIM varray *hl_alloc_array( hl_type *at, int size ) {
25 if( size == 0 && at->kind == HDYN ) {
26 static varray empty_array = { &hlt_array, &hlt_dyn };
27 return &empty_array;
28 }
29 int esize = hl_type_size(at);
30 varray *a;
31 if( size < 0 ) hl_error("Invalid array size");
32 a = (varray*)hl_gc_alloc_gen(&hlt_array, sizeof(varray) + esize*size, (hl_is_ptr(at) ? MEM_KIND_DYNAMIC : MEM_KIND_NOPTR) | MEM_ZERO);
33 a->t = &hlt_array;
34 a->at = at;
35 a->size = size;
36 return a;
37}
38
39HL_PRIM void hl_array_blit( varray *dst, int dpos, varray *src, int spos, int len ) {
40 int size = hl_type_size(dst->at);

Callers 15

_MNAME(keys)Function · 0.85
_MNAME(values)Function · 0.85
hl_wrapper_callFunction · 0.85
hl_obj_fieldsFunction · 0.85
hl_exception_stackFunction · 0.85
hl_sys_envFunction · 0.85
hl_sys_statFunction · 0.85
hl_sys_read_dirFunction · 0.85
hl_sys_argsFunction · 0.85
hl_type_enum_fieldsFunction · 0.85
hl_type_enum_valuesFunction · 0.85
hl_type_instance_fieldsFunction · 0.85

Calls 2

hl_type_sizeFunction · 0.85
hl_gc_alloc_genFunction · 0.85

Tested by

no test coverage detected