Skip to content

Commit

Permalink
GridFS can now use any buffer size when writing
Browse files Browse the repository at this point in the history
  • Loading branch information
SteenLund committed Jul 14, 2011
1 parent 5fc9b15 commit 5b678d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gridfs.c
Expand Up @@ -262,6 +262,8 @@ void gridfile_write_buffer( gridfile* gfile, const char* data, gridfs_offset len
char* buffer; char* buffer;
bson* oChunk; bson* oChunk;
gridfs_offset to_write = length + gfile->pending_len; gridfs_offset to_write = length + gfile->pending_len;
chunks_to_write = to_write / DEFAULT_CHUNK_SIZE;
bytes_left = to_write % DEFAULT_CHUNK_SIZE;


if ( to_write < DEFAULT_CHUNK_SIZE ) { /* Less than one chunk to write */ if ( to_write < DEFAULT_CHUNK_SIZE ) { /* Less than one chunk to write */
if( gfile->pending_data ) { if( gfile->pending_data ) {
Expand All @@ -279,8 +281,6 @@ void gridfile_write_buffer( gridfile* gfile, const char* data, gridfs_offset len
* the buffer provided up to DEFAULT_CHUNK_SIZE. * the buffer provided up to DEFAULT_CHUNK_SIZE.
*/ */
if ( gfile->pending_len > 0 ) { if ( gfile->pending_len > 0 ) {
chunks_to_write = to_write / DEFAULT_CHUNK_SIZE;
bytes_left = to_write % DEFAULT_CHUNK_SIZE;


data_partial_len = DEFAULT_CHUNK_SIZE - gfile->pending_len; data_partial_len = DEFAULT_CHUNK_SIZE - gfile->pending_len;
buffer = (char *)bson_malloc( DEFAULT_CHUNK_SIZE ); buffer = (char *)bson_malloc( DEFAULT_CHUNK_SIZE );
Expand Down

0 comments on commit 5b678d4

Please sign in to comment.