Skip to content

Commit

Permalink
avoid to gc
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed May 16, 2019
1 parent fed2fcf commit 5519a9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
20 changes: 6 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
language: go
go:
- '1.2.x'
- '1.3.x'
- '1.4.x'
- '1.5.x'
- '1.6.x'
- '1.7.x'
- '1.8.x'
- '1.9.x'
- '1.10.x'
- '1.11.x'
- 'tip'
- '1.11.x'
- '1.12.x'
- 'tip'
sudo: true
before_install:
- ./travis-mecab-install.sh
- export CGO_LDFLAGS="`mecab-config --libs`"
- export CGO_CFLAGS="-I`mecab-config --inc-dir`"
- ./travis-mecab-install.sh
- export CGO_LDFLAGS="`mecab-config --libs`"
- export CGO_CFLAGS="-I`mecab-config --inc-dir`"
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module github.com/shogo82148/go-mecab

go 1.12
3 changes: 3 additions & 0 deletions mecab.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"reflect"
"unsafe"
"runtime"
)

// MeCab is a morphological parser.
Expand Down Expand Up @@ -67,6 +68,7 @@ func (m MeCab) Parse(s string) (string, error) {
if result == nil {
return "", m.Error()
}
runtime.KeepAlive(s)
return C.GoString(result), nil
}

Expand Down Expand Up @@ -96,6 +98,7 @@ func (m MeCab) ParseToNode(s string) (Node, error) {
if node == nil {
return Node{}, m.Error()
}
runtime.KeepAlive(s)
return Node{node: node}, nil
}

Expand Down

0 comments on commit 5519a9f

Please sign in to comment.