Skip to content

Commit

Permalink
Fix memory leak in new column family metadata (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus authored Nov 9, 2023
1 parent 0637613 commit 3e916a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cf_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grocksdb

// #include "rocksdb/c.h"
import "C"
import "unsafe"

// ColumnFamilyMetadata contains metadata info of column family.
type ColumnFamilyMetadata struct {
Expand Down Expand Up @@ -98,10 +99,12 @@ func sstMetas(c *C.rocksdb_level_metadata_t) []SstMetadata {

var ln C.size_t
sk := C.rocksdb_sst_file_metadata_get_smallestkey(sm, &ln)
metas[i].smallestKey = charToByte(sk, ln)
metas[i].smallestKey = C.GoBytes(unsafe.Pointer(sk), C.int(ln))
C.rocksdb_free(unsafe.Pointer(sk))

sk = C.rocksdb_sst_file_metadata_get_largestkey(sm, &ln)
metas[i].largestKey = charToByte(sk, ln)
metas[i].largestKey = C.GoBytes(unsafe.Pointer(sk), C.int(ln))
C.rocksdb_free(unsafe.Pointer(sk))

C.rocksdb_sst_file_metadata_destroy(sm)
}
Expand Down

0 comments on commit 3e916a2

Please sign in to comment.