Skip to content

Commit 995e6ba

Browse files
committed
output: fix misuse of unsafe.Pointer
Closes #18. Signed-off-by: Zero King <[email protected]>
1 parent 215d680 commit 995e6ba

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

output/output.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ func FLBPluginConfigKey(plugin unsafe.Pointer, key string) string {
6969
return value
7070
}
7171

72-
var contexts []interface{}
72+
var contexts = make(map[uintptr]interface{})
7373

7474
func FLBPluginSetContext(plugin unsafe.Pointer, ctx interface{}) {
75-
i := len(contexts)
76-
contexts = append(contexts, ctx)
75+
i := unsafe.Pointer(C.CString(""))
76+
contexts[uintptr(i)] = ctx
7777
p := (*FLBOutPlugin)(plugin)
78-
p.context.remote_context = unsafe.Pointer(uintptr(i))
78+
p.context.remote_context = i
7979
}
8080

8181
func FLBPluginGetContext(i unsafe.Pointer) interface{} {
82-
return contexts[int(uintptr(i))]
82+
return contexts[uintptr(i)]
8383
}

0 commit comments

Comments
 (0)