Skip to content

Commit df29826

Browse files
committed
Fixing comments.
1 parent 02d637a commit df29826

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

roaring.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ func (rb *Bitmap) ReadFrom(stream io.Reader) (int64, error) {
8686
// You should *not* change the copy-on-write status of the resulting
8787
// bitmaps (SetCopyOnWrite).
8888
//
89+
// If buf becomes unavailable, then a bitmap created with
90+
// FromBuffer would be effectively broken. Furthermore, any
91+
// bitmap derived from this bitmap (e.g., via Or, And) might
92+
// also be broken. Thus, before making buf unavailable, you should
93+
// call CloneCopyOnWriteContainers on all such bitmaps.
94+
//
8995
func (rb *Bitmap) FromBuffer(buf []byte) (int64, error) {
9096
return rb.highlowcontainer.fromBuffer(buf)
9197
}
@@ -1363,9 +1369,17 @@ func (rb *Bitmap) GetCopyOnWrite() (val bool) {
13631369
return rb.highlowcontainer.copyOnWrite
13641370
}
13651371

1366-
// clone all containers which have needCopyOnWrite set to true
1372+
// CloneCopyOnWriteContainers clones all containers which have
1373+
// needCopyOnWrite set to true.
13671374
// This can be used to make sure it is safe to munmap a []byte
1368-
// that the roaring array may still have a reference to.
1375+
// that the roaring array may still have a reference to, after
1376+
// calling FromBuffer.
1377+
// More generally this function is useful if you call FromBuffer
1378+
// to construct a bitmap with a backing array buf
1379+
// and then later discard the buf array. Note that you should call
1380+
// CloneCopyOnWriteContainers on all bitmaps that were derived
1381+
// from the 'FromBuffer' bitmap since they map have dependencies
1382+
// on the buf array as well.
13691383
func (rb *Bitmap) CloneCopyOnWriteContainers() {
13701384
rb.highlowcontainer.cloneCopyOnWriteContainers()
13711385
}

0 commit comments

Comments
 (0)