Skip to content

Commit f761860

Browse files
authored
Export jl_alloc_array_nd, re-add and export convenience wrappers (#52248)
This is used in an example here in the docs https://docs.julialang.org/en/v1.11-dev/manual/embedding/#Multidimensional-Arrays and needed to adapt to the removed `jl_alloc_array_2d` (#51319).
1 parent e280387 commit f761860

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/array.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ JL_DLLEXPORT jl_array_t *jl_alloc_array_1d(jl_value_t *atype, size_t nr)
167167
return new_array(atype, 1, &nr);
168168
}
169169

170+
JL_DLLEXPORT jl_array_t *jl_alloc_array_2d(jl_value_t *atype, size_t nr, size_t nc)
171+
{
172+
size_t dims[2] = {nr, nc};
173+
return new_array(atype, 2, &dims[0]);
174+
}
175+
176+
JL_DLLEXPORT jl_array_t *jl_alloc_array_3d(jl_value_t *atype, size_t nr, size_t nc, size_t z)
177+
{
178+
size_t dims[3] = {nr, nc, z};
179+
return new_array(atype, 3, &dims[0]);
180+
}
181+
170182
JL_DLLEXPORT jl_array_t *jl_alloc_array_nd(jl_value_t *atype, size_t *dims, size_t ndims)
171183
{
172184
return new_array(atype, ndims, dims);

src/jl_exported_funcs.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
XX(jl_adopt_thread) \
77
XX(jl_alignment) \
88
XX(jl_alloc_array_1d) \
9+
XX(jl_alloc_array_2d) \
10+
XX(jl_alloc_array_3d) \
11+
XX(jl_alloc_array_nd) \
912
XX(jl_alloc_string) \
1013
XX(jl_alloc_svec) \
1114
XX(jl_alloc_svec_uninit) \

src/julia.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,9 @@ JL_DLLEXPORT jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data,
18281828
jl_value_t *dims, int own_buffer);
18291829

18301830
JL_DLLEXPORT jl_array_t *jl_alloc_array_1d(jl_value_t *atype, size_t nr);
1831+
JL_DLLEXPORT jl_array_t *jl_alloc_array_2d(jl_value_t *atype, size_t nr, size_t nc);
1832+
JL_DLLEXPORT jl_array_t *jl_alloc_array_3d(jl_value_t *atype, size_t nr, size_t nc, size_t z);
1833+
JL_DLLEXPORT jl_array_t *jl_alloc_array_nd(jl_value_t *atype, size_t *dims, size_t ndims);
18311834
JL_DLLEXPORT jl_array_t *jl_pchar_to_array(const char *str, size_t len);
18321835
JL_DLLEXPORT jl_value_t *jl_pchar_to_string(const char *str, size_t len);
18331836
JL_DLLEXPORT jl_value_t *jl_cstr_to_string(const char *str);

0 commit comments

Comments
 (0)