File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,14 @@ func FLBPluginConfigKey(plugin unsafe.Pointer, key string) string {
7272var contexts = make (map [uintptr ]interface {})
7373
7474func FLBPluginSetContext (plugin unsafe.Pointer , ctx interface {}) {
75+ // Allocate a byte of memory in the C heap and fill it with '\0',
76+ // then convert its pointer into the C type void*, represented by unsafe.Pointer.
77+ // The C string is not managed by Go GC, so it will not be freed automatically.
7578 i := unsafe .Pointer (C .CString ("" ))
79+ // uintptr(i) produces the memory address of i, and malloc() guarantees uniqueness of it.
80+ //
81+ // FLBPluginSetContext must not be called concurrently with itself or FLBPluginGetContext.
82+ // A sync.RWMutex must be added if this might happen.
7683 contexts [uintptr (i )] = ctx
7784 p := (* FLBOutPlugin )(plugin )
7885 p .context .remote_context = i
You can’t perform that action at this time.
0 commit comments