cubefs/vendor/github.com/tecbot/gorocksdb/array.go
yuxiaobo ac75137295 build: the build script of blobstore is merged into cubefs
1. rocksdb upgrade to 6.3.6
2. optimize the build scripts
3. fix build errors
4. add env variable for blobstore unit test
5. update git ignore file to ignore build and test result
6. modify open files limit for unit test

Signed-off-by: yuxiaobo <yuxiaobo@oppo.com>
Signed-off-by: slasher <shenjie1@oppo.com>
Signed-off-by: Victor1319 <834863182@qq.com>
2023-05-23 15:24:53 +08:00

55 lines
1.4 KiB
Go

package gorocksdb
// #include "stdlib.h"
// #include "rocksdb/c.h"
import "C"
import (
"reflect"
"unsafe"
)
type charsSlice []*C.char
type sizeTSlice []C.size_t
type columnFamilySlice []*C.rocksdb_column_family_handle_t
func (s charsSlice) c() **C.char {
sH := (*reflect.SliceHeader)(unsafe.Pointer(&s))
return (**C.char)(unsafe.Pointer(sH.Data))
}
func (s sizeTSlice) c() *C.size_t {
sH := (*reflect.SliceHeader)(unsafe.Pointer(&s))
return (*C.size_t)(unsafe.Pointer(sH.Data))
}
func (s columnFamilySlice) c() **C.rocksdb_column_family_handle_t {
sH := (*reflect.SliceHeader)(unsafe.Pointer(&s))
return (**C.rocksdb_column_family_handle_t)(unsafe.Pointer(sH.Data))
}
// bytesSliceToCSlices converts a slice of byte slices to two slices with C
// datatypes. One containing pointers to copies of the byte slices and one
// containing their sizes.
// IMPORTANT: All the contents of the charsSlice array are malloced and
// should be freed using the Destroy method of charsSlice.
func byteSlicesToCSlices(vals [][]byte) (charsSlice, sizeTSlice) {
if len(vals) == 0 {
return nil, nil
}
chars := make(charsSlice, len(vals))
sizes := make(sizeTSlice, len(vals))
for i, val := range vals {
chars[i] = (*C.char)(C.CBytes(val))
sizes[i] = C.size_t(len(val))
}
return chars, sizes
}
func (s charsSlice) Destroy() {
for _, chars := range s {
C.free(unsafe.Pointer(chars))
}
}