Skip to content

Commit

Permalink
Remove keep stream, issue #108
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2brain committed Oct 1, 2024
1 parent 21ad9aa commit a899437
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 1 addition & 3 deletions fitz_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ func NewFromMemory(b []byte) (f *Document, err error) {

C.fz_register_document_handlers(f.ctx)

stream := C.fz_open_memory(f.ctx, (*C.uchar)(&b[0]), C.size_t(len(b)))
f.stream = C.fz_keep_stream(f.ctx, stream)

f.stream = C.fz_open_memory(f.ctx, (*C.uchar)(&b[0]), C.size_t(len(b)))
if f.stream == nil {
err = ErrOpenMemory
return
Expand Down
6 changes: 1 addition & 5 deletions fitz_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ func NewFromMemory(b []byte) (f *Document, err error) {

fzRegisterDocumentHandlers(f.ctx)

stream := fzOpenMemory(f.ctx, unsafe.SliceData(b), uint64(len(b)))
f.stream = fzKeepStream(f.ctx, stream)

f.stream = fzOpenMemory(f.ctx, unsafe.SliceData(b), uint64(len(b)))
if f.stream == nil {
err = ErrOpenMemory
return
Expand Down Expand Up @@ -533,7 +531,6 @@ var (
fzOpenDocument func(ctx *fzContext, filename string) *fzDocument
fzOpenDocumentWithStream func(ctx *fzContext, magic string, stream *fzStream) *fzDocument
fzOpenMemory func(ctx *fzContext, data *uint8, len uint64) *fzStream
fzKeepStream func(ctx *fzContext, stm *fzStream) *fzStream
fzDropStream func(ctx *fzContext, stm *fzStream)
fzRegisterDocumentHandlers func(ctx *fzContext)
fzNeedsPassword func(ctx *fzContext, doc *fzDocument) int
Expand Down Expand Up @@ -591,7 +588,6 @@ func init() {
purego.RegisterLibFunc(&fzOpenDocument, libmupdf, "fz_open_document")
purego.RegisterLibFunc(&fzOpenDocumentWithStream, libmupdf, "fz_open_document_with_stream")
purego.RegisterLibFunc(&fzOpenMemory, libmupdf, "fz_open_memory")
purego.RegisterLibFunc(&fzKeepStream, libmupdf, "fz_keep_stream")
purego.RegisterLibFunc(&fzDropStream, libmupdf, "fz_drop_stream")
purego.RegisterLibFunc(&fzRegisterDocumentHandlers, libmupdf, "fz_register_document_handlers")
purego.RegisterLibFunc(&fzNeedsPassword, libmupdf, "fz_needs_password")
Expand Down

0 comments on commit a899437

Please sign in to comment.