File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,13 @@ package ui
4
4
5
5
// #include <stdlib.h>
6
6
// #include "ui.h"
7
+ // // TODO figure this one out
8
+ // extern void *uimalloc(size_t);
7
9
// static uiDrawBrush *newBrush(void)
8
10
// {
9
11
// uiDrawBrush *b;
10
12
//
11
- // b = (uiDrawBrush *) malloc(sizeof (uiDrawBrush));
12
- // // TODO
13
+ // b = (uiDrawBrush *) uimalloc(sizeof (uiDrawBrush));
13
14
// return b;
14
15
// }
15
16
// static uiDrawBrushGradientStop *newStops(size_t n)
Original file line number Diff line number Diff line change @@ -7,8 +7,22 @@ import (
7
7
)
8
8
9
9
// #include <stdlib.h>
10
+ // // TODO remove when switching to Go 1.7
11
+ // #include <string.h>
10
12
import "C"
11
13
14
+ // TODO move this to C.CBytes() when switching to Go 1.7
15
+
16
+ //export uimalloc
17
+ func uimalloc (n C.size_t ) unsafe.Pointer {
18
+ p := C .malloc (n )
19
+ if p == nil {
20
+ panic ("out of memory in uimalloc()" )
21
+ }
22
+ C .memset (p , 0 , n )
23
+ return p
24
+ }
25
+
12
26
func freestr (str * C.char ) {
13
27
C .free (unsafe .Pointer (str ))
14
28
}
You can’t perform that action at this time.
0 commit comments