Reader/Writer should implement Close() to free convertor
This commit is contained in:
parent
8960e66bd3
commit
181ac22e08
@ -5,6 +5,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This implements io.ReadCloser interface
|
||||||
type Reader struct {
|
type Reader struct {
|
||||||
source io.Reader
|
source io.Reader
|
||||||
converter *Converter
|
converter *Converter
|
||||||
@ -61,6 +62,11 @@ func (this *Reader) fillBuffer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Must be called to free memory
|
||||||
|
func (this *Reader) Close() error {
|
||||||
|
return this.converter.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// implement the io.Reader interface
|
// implement the io.Reader interface
|
||||||
func (this *Reader) Read(p []byte) (n int, err error) {
|
func (this *Reader) Read(p []byte) (n int, err error) {
|
||||||
// checks for when we have no data
|
// checks for when we have no data
|
||||||
|
@ -2,6 +2,7 @@ package iconv
|
|||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
|
// This implements io.WriteCloser interface
|
||||||
type Writer struct {
|
type Writer struct {
|
||||||
destination io.Writer
|
destination io.Writer
|
||||||
converter *Converter
|
converter *Converter
|
||||||
@ -58,6 +59,11 @@ func (this *Writer) emptyBuffer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Must be called to free memory
|
||||||
|
func (this *Writer) Close() error {
|
||||||
|
return this.converter.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// implement the io.Writer interface
|
// implement the io.Writer interface
|
||||||
func (this *Writer) Write(p []byte) (n int, err error) {
|
func (this *Writer) Write(p []byte) (n int, err error) {
|
||||||
// write data into our internal buffer
|
// write data into our internal buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user