diff options
| author | Ian Lance Taylor <iant@golang.org> | 2012-11-10 11:19:06 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2012-11-10 11:19:06 -0800 |
| commit | e9a3087e290b52212af1ca2001ea9b24d8797fd0 (patch) | |
| tree | 00aa2dc3061a8c72c4d43f496ae922565cb9132d /src/pkg/runtime/cgo/callbacks.c | |
| parent | 5612edb13e5a772e79ade881038ee0760df70d8c (diff) | |
| download | go-e9a3087e290b52212af1ca2001ea9b24d8797fd0.tar.xz | |
runtime, runtime/cgo: track memory allocated by non-Go code
Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.
R=golang-dev, dave, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6819119
Diffstat (limited to 'src/pkg/runtime/cgo/callbacks.c')
| -rw-r--r-- | src/pkg/runtime/cgo/callbacks.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/runtime/cgo/callbacks.c b/src/pkg/runtime/cgo/callbacks.c index f36fb3fd7e..cefd67de87 100644 --- a/src/pkg/runtime/cgo/callbacks.c +++ b/src/pkg/runtime/cgo/callbacks.c @@ -33,7 +33,13 @@ static void _cgo_allocate_internal(uintptr len, byte *ret) { + CgoMal *c; + ret = runtimeĀ·mal(len); + c = runtimeĀ·mal(sizeof(*c)); + c->next = m->cgomal; + c->alloc = ret; + m->cgomal = c; FLUSH(&ret); } |
