mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 00:13:49 +01:00
librclone: add RcloneFreeString function
See PR #5703 Based on initial work by Weng Haoyu (@wengh) in PR #5362
This commit is contained in:
parent
c7329d2ece
commit
85074f8f88
@ -31,6 +31,7 @@ For documentation see the Go documentation for:
|
|||||||
- [RcloneInitialize](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneInitialize)
|
- [RcloneInitialize](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneInitialize)
|
||||||
- [RcloneFinalize](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneFinalize)
|
- [RcloneFinalize](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneFinalize)
|
||||||
- [RcloneRPC](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneRPC)
|
- [RcloneRPC](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneRPC)
|
||||||
|
- [RcloneFreeString](https://pkg.go.dev/github.com/rclone/rclone/librclone#RcloneFreeString)
|
||||||
|
|
||||||
### C Example
|
### C Example
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct RcloneRPCResult {
|
struct RcloneRPCResult {
|
||||||
char* Output;
|
char* Output;
|
||||||
int Status;
|
int Status;
|
||||||
@ -28,6 +30,8 @@ struct RcloneRPCResult {
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/rclone/rclone/librclone/librclone"
|
"github.com/rclone/rclone/librclone/librclone"
|
||||||
|
|
||||||
_ "github.com/rclone/rclone/backend/all" // import all backends
|
_ "github.com/rclone/rclone/backend/all" // import all backends
|
||||||
@ -79,5 +83,17 @@ func RcloneRPC(method *C.char, input *C.char) (result C.struct_RcloneRPCResult)
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RcloneFreeString may be used to free the string returned by RcloneRPC
|
||||||
|
//
|
||||||
|
// If the caller has access to the C standard library, the free function can
|
||||||
|
// normally be called directly instead. In some cases the caller uses a
|
||||||
|
// runtime library which is not compatible, and then this function can be
|
||||||
|
// used to release the memory with the same library that allocated it.
|
||||||
|
//
|
||||||
|
//export RcloneFreeString
|
||||||
|
func RcloneFreeString(str *C.char) {
|
||||||
|
C.free(unsafe.Pointer(str))
|
||||||
|
}
|
||||||
|
|
||||||
// do nothing here - necessary for building into a C library
|
// do nothing here - necessary for building into a C library
|
||||||
func main() {}
|
func main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user