Skip to content
Browse files

Use const void* instead of const char* as data parameter of

appendBinData/appendBinDataArrayDeprecated

There is no much sense in explicit conversion of void pointers to
char pointers only to convert them back.
  • Loading branch information...
1 parent 03dbe74 commit e25062faf5045009d2fad4698792eae4419a6f36 Yakov Markovitch committed with erh Oct 15, 2011
Showing with 4 additions and 7 deletions.
  1. +4 −7 bson/bsonobjbuilder.h
View
11 bson/bsonobjbuilder.h
@@ -469,31 +469,28 @@ namespace mongo {
Use BinDataGeneral if you don't care about the type.
@param data the byte array
*/
- BSONObjBuilder& appendBinData( const StringData& fieldName, int len, BinDataType type, const char *data ) {
+ BSONObjBuilder& appendBinData( const StringData& fieldName, int len, BinDataType type, const void *data ) {
_b.appendNum( (char) BinData );
_b.appendStr( fieldName );
_b.appendNum( len );
_b.appendNum( (char) type );
- _b.appendBuf( (void *) data, len );
+ _b.appendBuf( data, len );
return *this;
}
- BSONObjBuilder& appendBinData( const StringData& fieldName, int len, BinDataType type, const unsigned char *data ) {
- return appendBinData(fieldName, len, type, (const char *) data);
- }
/**
Subtype 2 is deprecated.
Append a BSON bindata bytearray element.
@param data a byte array
@param len the length of data
*/
- BSONObjBuilder& appendBinDataArrayDeprecated( const char * fieldName , const char * data , int len ) {
+ BSONObjBuilder& appendBinDataArrayDeprecated( const char * fieldName , const void * data , int len ) {
_b.appendNum( (char) BinData );
_b.appendStr( fieldName );
_b.appendNum( len + 4 );
_b.appendNum( (char)0x2 );
_b.appendNum( len );
- _b.appendBuf( (void *) data, len );
+ _b.appendBuf( data, len );
return *this;
}

0 comments on commit e25062f

Please sign in to comment.
Something went wrong with that request. Please try again.