Skip to content

Commit

Permalink
[cgo] refs fibercrypto#116 Clena memory to handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Feb 2, 2020
1 parent f8a5239 commit a68941d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions lib/cgo/libsky_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ func libErrorCode(err error) uint32 {
return SKY_ERROR
}

// nolint unused
func errorFromLibCode(errcode uint32) error {
if err, exists := codeToErrorMap[errcode]; exists {
return err
Expand Down
9 changes: 2 additions & 7 deletions lib/cgo/libsky_mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"reflect"
"unsafe"

"github.com/spf13/cobra"

"github.com/SkycoinProject/skycoin/src/cipher"
httphelper "github.com/SkycoinProject/skycoin/src/util/http"
)
Expand All @@ -22,6 +20,7 @@ import (
*/
import "C"

// nolint unused
const (
SizeofRipemd160 = unsafe.Sizeof(C.cipher__Ripemd160{})
SizeOfAddress = unsafe.Sizeof(C.cipher__Address{})
Expand Down Expand Up @@ -50,11 +49,6 @@ func inplaceHttpHelperAddress(p *C.httphelper__Address) *httphelper.Address {
return (*httphelper.Address)(unsafe.Pointer(p))
}

func inplaceCobraCommand(p interface{}) (cmd *cobra.Command, isInstance bool) {
cmd, isInstance = p.(*cobra.Command)
return
}

/**
* Copy helpers
*/
Expand Down Expand Up @@ -127,6 +121,7 @@ func copyToGoSlice(src reflect.Value, dest *C.GoSlice_) {
}
}

// nolint unused
func copyToStringMap(gomap map[string]string, dest *C.GoStringMap_) {
*dest = (C.GoStringMap_)(registerHandle(gomap))
}
Expand Down
13 changes: 0 additions & 13 deletions lib/cgo/libsky_types.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package main

import (
cipher "github.com/SkycoinProject/skycoin/src/cipher"
)

/*
#include <string.h>
Expand All @@ -12,12 +8,3 @@ import (
#include "skytypes.h"
*/
import "C"

func toAddresserArray(addrs []cipher.Address) []cipher.Addresser {
// TODO : Support for arrays of interface objects in cgogen
var __addrs = make([]cipher.Addresser, len(addrs))
for _, addr := range addrs {
__addrs = append(__addrs, addr)
}
return __addrs
}

0 comments on commit a68941d

Please sign in to comment.