summaryrefslogtreecommitdiff
path: root/handles.go
AgeCommit message (Collapse)Author
2021-09-05Make all non-user-creatable structures non-comparable (#802)lhchavez
This change makes all non-user-creatable structures non-comparable. This makes it easier to add changes later that don't introduce breaking changes from the go compatibility guarantees perspective. This, of course, implies that this change _is_ a breaking change, but since these structures are not intended to be created by users (or de-referenced), it should be okay.
2020-06-21Add a way to cleanly shut down the library (#578)lhchavez
This change adds the Shutdown() method, so that the library can be cleanly shut down. This helps significanly reduce the amount of noise in the leak detector.
2016-02-18handles: use real pointers to keep track of handlesCarlos Martín Nieto
With the change to 1.6 rules, we couldn't use the Go pointers, so we went with casting the list indices into pointers. The runtime does not like this, however. It will sometimes detect that we have a pointer with a very small value and consider it an invalid pointer, bringing down the application with it. Work around that by asking libc for the smallest amount of memory it'll give us so we have an actual allocated pointer to use. We then use this pointer value as the key in our map to find the Go object we're tracking.
2016-02-16handles, merge: simplify code, don't copy file contentsIan Lance Taylor
2016-01-07handles, merge, odb: changes for Go 1.6 pointer passing rulesIan Lance Taylor
See http://tip.golang.org/cmd/cgo/#hdr-Passing_pointers .
2015-07-26Prevent slot int variable from being GCed.Dmitri Shuralyov
Before this change, there were no users of slot int variable in the Go world (just a pointer to it that ended up in C world only), so Go's garbage collector would free it and its value could not retrieved later (once a pointer to it comes back to Go world from C world). Keep a pointer to it in the Go world so that does not happen. Fixes #218.
2015-05-22handles: do not store handles by uintptrPatrick Steinhardt
If we store values by uintptrs the GC may try to inspect their values when it kicks in. As the pointers are most likely invalid, this will result in an invalid pointer dereference, causing the program to panic. We can fix this by storing values by an int index value instead, returning pointers to those indices as handles instead.
2015-05-22handles: print pointer handle on panic.Patrick Steinhardt
2015-05-22handles: start slot indices with 1Patrick Steinhardt
Using 0 as the first slot indice leads to not being able to differentiate between a handle to the first element or a NULL-handle. As current code may check whether the pointer is NULL, change the first indice to be 1 instead.
2015-05-22handles: correctly initialize all membersPatrick Steinhardt
2015-05-22Introduce an indirection layer for pointersCarlos Martín Nieto
As the Go runtime can move stacks at any point and the C code runs concurrently with the rest of the system, we cannot assume that the payloads we give to the C code will stay valid for any particular duration. We must therefore give the C code handles which we can then look up in our own list when the callbacks get called.