Fix memleak in signal package (#1114)
This commit is contained in:
parent
f0f1b8d783
commit
60249e4682
|
@ -3,6 +3,7 @@ package signal
|
||||||
/*
|
/*
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
extern bool StatusServiceSignalEvent(const char *jsonEvent);
|
extern bool StatusServiceSignalEvent(const char *jsonEvent);
|
||||||
extern void SetEventCallback(void *cb);
|
extern void SetEventCallback(void *cb);
|
||||||
*/
|
*/
|
||||||
|
@ -40,8 +41,12 @@ func send(typ string, event interface{}) {
|
||||||
data, err := json.Marshal(&signal)
|
data, err := json.Marshal(&signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Marshalling signal envelope", "error", err)
|
logger.Error("Marshalling signal envelope", "error", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
C.StatusServiceSignalEvent(C.CString(string(data)))
|
|
||||||
|
str := C.CString(string(data))
|
||||||
|
C.StatusServiceSignalEvent(str)
|
||||||
|
C.free(unsafe.Pointer(str))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeNotificationHandler defines a handler able to process incoming node events.
|
// NodeNotificationHandler defines a handler able to process incoming node events.
|
||||||
|
@ -83,7 +88,9 @@ func NotifyNode(jsonEvent *C.char) {
|
||||||
//export TriggerTestSignal
|
//export TriggerTestSignal
|
||||||
//nolint: golint
|
//nolint: golint
|
||||||
func TriggerTestSignal() {
|
func TriggerTestSignal() {
|
||||||
C.StatusServiceSignalEvent(C.CString(`{"answer": 42}`))
|
str := C.CString(`{"answer": 42}`)
|
||||||
|
C.StatusServiceSignalEvent(str)
|
||||||
|
C.free(unsafe.Pointer(str))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSignalEventCallback set callback
|
// SetSignalEventCallback set callback
|
||||||
|
|
Loading…
Reference in New Issue