mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
issue: #30926, #33132 - implement future-based cgo utility. --------- Signed-off-by: chyezh <chyezh@outlook.com>
28 lines
494 B
Go
28 lines
494 B
Go
package cgo
|
|
|
|
/*
|
|
#cgo pkg-config: milvus_common
|
|
|
|
#include "common/type_c.h"
|
|
#include <stdlib.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
|
)
|
|
|
|
func ConsumeCStatusIntoError(status *C.CStatus) error {
|
|
if status.error_code == 0 {
|
|
return nil
|
|
}
|
|
errorCode := status.error_code
|
|
errorMsg := C.GoString(status.error_msg)
|
|
getCGOCaller().call("free", func() {
|
|
C.free(unsafe.Pointer(status.error_msg))
|
|
})
|
|
return merr.SegcoreError(int32(errorCode), errorMsg)
|
|
}
|