Zero-fill pkguiAlloc()'s output.
This commit is contained in:
parent
d8200a9f04
commit
c90187046a
1
pkgui.h
1
pkgui.h
|
@ -3,6 +3,7 @@
|
||||||
#define pkguiHFileIncluded
|
#define pkguiHFileIncluded
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
|
|
6
util.go
6
util.go
|
@ -12,8 +12,10 @@ import "C"
|
||||||
//export pkguiAlloc
|
//export pkguiAlloc
|
||||||
func pkguiAlloc(n C.size_t) unsafe.Pointer {
|
func pkguiAlloc(n C.size_t) unsafe.Pointer {
|
||||||
// cgo turns C.malloc() into a panic-on-OOM version; use it
|
// cgo turns C.malloc() into a panic-on-OOM version; use it
|
||||||
// TODO make sure it zero-initializes too
|
ret := C.malloc(n)
|
||||||
return C.malloc(n)
|
// and this won't zero-initialize; do it ourselves
|
||||||
|
C.memset(ret, 0, n)
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func freestr(str *C.char) {
|
func freestr(str *C.char) {
|
||||||
|
|
Loading…
Reference in New Issue