Skip to content

Commit

Permalink
go: Call 'heif_context_read_from_memory_without_copy' instead of depr…
Browse files Browse the repository at this point in the history
…ecated function

heif.c:319 says:
    // DEPRECATED: use heif_context_read_from_memory_without_copy() instead.
  • Loading branch information
Leon Klingele committed Aug 21, 2018
1 parent 198d64d commit ff75b2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/heif/heif.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,12 @@ func (c *Context) ReadFromFile(filename string) error {

func (c *Context) ReadFromMemory(data []byte) error {
// TODO: Use reader API internally.
err := C.heif_context_read_from_memory(c.context, unsafe.Pointer(&data[0]), C.size_t(len(data)), nil)
cData := C.CBytes(data)
runtime.SetFinalizer(&cData, func(p *unsafe.Pointer) {
C.free(*p)
runtime.SetFinalizer(cData, nil)
})
err := C.heif_context_read_from_memory_without_copy(c.context, cData, C.size_t(len(data)), nil)
return convertHeifError(err)
}

Expand Down

0 comments on commit ff75b2d

Please sign in to comment.