|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | + |
| 17 | +//go:build go1.20 || tinygo |
| 18 | + |
| 19 | +package cdata |
| 20 | + |
| 21 | +// #include <stdlib.h> |
| 22 | +// #include "arrow/c/abi.h" |
| 23 | +import "C" |
| 24 | + |
| 25 | +import ( |
| 26 | + "unsafe" |
| 27 | +) |
| 28 | + |
| 29 | +func allocateArrowSchemaArr(n int) (out []CArrowSchema) { |
| 30 | + return unsafe.Slice((*CArrowSchema)(C.calloc(C.size_t(n), |
| 31 | + C.sizeof_struct_ArrowSchema)), n) |
| 32 | +} |
| 33 | + |
| 34 | +func allocateArrowSchemaPtrArr(n int) (out []*CArrowSchema) { |
| 35 | + return unsafe.Slice((**CArrowSchema)(C.calloc(C.size_t(n), |
| 36 | + C.size_t(unsafe.Sizeof((*CArrowSchema)(nil))))), n) |
| 37 | +} |
| 38 | + |
| 39 | +func allocateArrowArrayArr(n int) (out []CArrowArray) { |
| 40 | + return unsafe.Slice((*CArrowArray)(C.calloc(C.size_t(n), |
| 41 | + C.sizeof_struct_ArrowArray)), n) |
| 42 | +} |
| 43 | + |
| 44 | +func allocateArrowArrayPtrArr(n int) (out []*CArrowArray) { |
| 45 | + return unsafe.Slice((**CArrowArray)(C.calloc(C.size_t(n), |
| 46 | + C.size_t(unsafe.Sizeof((*CArrowArray)(nil))))), n) |
| 47 | +} |
| 48 | + |
| 49 | +func allocateBufferPtrArr(n int) (out []*C.void) { |
| 50 | + return unsafe.Slice((**C.void)(C.calloc(C.size_t(n), |
| 51 | + C.size_t(unsafe.Sizeof((*C.void)(nil))))), n) |
| 52 | +} |
| 53 | + |
| 54 | +func allocateBufferSizeArr(n int) (out []C.int64_t) { |
| 55 | + return unsafe.Slice((*C.int64_t)(C.calloc(C.size_t(n), |
| 56 | + C.sizeof_int64_t)), n) |
| 57 | +} |
0 commit comments