summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2010-11-30 08:46:51 -0500
committerdwight <dwight@10gen.com>2010-11-30 08:46:51 -0500
commiteb5ac64eeb1b2782cbd3918bc59ad9cdb4996088 (patch)
tree3c60e63f9e2057ab0a3d173c4aee943f4e06c9f9 /bson
parent7ca8b464eb4892fc361d6c59cd0bb2e32be1fdc6 (diff)
downloadmongo-eb5ac64eeb1b2782cbd3918bc59ad9cdb4996088.tar.gz
comment
Diffstat (limited to 'bson')
-rw-r--r--bson/bsonobj.h11
-rw-r--r--bson/bsonobjbuilder.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/bson/bsonobj.h b/bson/bsonobj.h
index 629bc370d82..f5ce0109b6a 100644
--- a/bson/bsonobj.h
+++ b/bson/bsonobj.h
@@ -95,10 +95,15 @@ namespace mongo {
A BSONObj can also point to BSON data in some other data structure it does not "own" or free later.
For example, in a memory mapped file. In this case, it is important the original data stays in
scope for as long as the BSONObj is in use. If you think the original data may go out of scope,
- call BSONObj::getOwned() to promote your BSONObj to having its own copy. If you are not sure about
- ownership but need the buffer to last as long as the BSONObj, call getOwned(). getOwned() is a
- no-op if the buffer is already owned. If not already owned, a malloc and memcpy will result.
+ call BSONObj::getOwned() to promote your BSONObj to having its own copy.
+
+ On a BSONObj assignment, if the source is unowned, both the source and dest will have unowned
+ pointers to the original buffer after the assignment.
+ If you are not sure about ownership but need the buffer to last as long as the BSONObj, call
+ getOwned(). getOwned() is a no-op if the buffer is already owned. If not already owned, a malloc
+ and memcpy will result.
+
Most ways to create BSONObj's create 'owned' variants. Unowned versions can be created with:
(1) specifying true for the ifree parameter in the constructor
(2) calling BSONObjBuilder::done(). Use BSONObjBuilder::obj() to get an owned copy
diff --git a/bson/bsonobjbuilder.h b/bson/bsonobjbuilder.h
index d0238b98265..7eb57a2ecc6 100644
--- a/bson/bsonobjbuilder.h
+++ b/bson/bsonobjbuilder.h
@@ -85,6 +85,7 @@ namespace mongo {
_b.skip(4); /*leave room for size field*/
}
+ /* dm why do we have this/need this? not clear to me, comment please tx. */
/** @param baseBuilder construct a BSONObjBuilder using an existing BufBuilder */
BSONObjBuilder( BufBuilder &baseBuilder ) : _b( baseBuilder ), _buf( 0 ), _offset( baseBuilder.len() ), _s( this ) , _tracker(0) , _doneCalled(false) {
_b.skip( 4 );