-
Notifications
You must be signed in to change notification settings - Fork 2
/
object.go
45 lines (38 loc) · 593 Bytes
/
object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package hdf5
// #include <stdlib.h>
// #include <hdf5.h>
import "C"
import (
"unsafe"
)
const (
flagVariableLength = 1 << iota
flagOwnedMemory
)
type object struct {
data unsafe.Pointer
flag uint8
tid C.hid_t
deps []*object
}
func newObject() *object {
return &object{
tid: -1,
}
}
func (o *object) new() *object {
object := newObject()
o.deps = append(o.deps, object)
return object
}
func (o *object) free() {
for i := range o.deps {
o.deps[i].free()
}
if o.tid >= 0 {
C.H5Tclose(o.tid)
}
if o.data != nil && o.flag&flagOwnedMemory != 0 {
C.free(o.data)
}
}