Fossil SCM

Added blob_reserve() for use with a manifest-generation optimization.

stephan 2020-05-01 05:37 UTC checkin-without-checkout
Commit 972cc5f9ac23a8dcd465886a726332400db7df64d95335eee702d7ef9265369a
1 file changed +12
+12
--- src/blob.c
+++ src/blob.c
@@ -477,10 +477,22 @@
477477
void blob_resize(Blob *pBlob, unsigned int newSize){
478478
pBlob->xRealloc(pBlob, newSize+1);
479479
pBlob->nUsed = newSize;
480480
pBlob->aData[newSize] = 0;
481481
}
482
+
483
+/*
484
+** Ensures that the given blob has at least the given amount of memory
485
+** allocated to it. Does not modify pBlob->nUsed nor will it reduce
486
+** the currently-allocated amount of memory.
487
+*/
488
+void blob_reserve(Blob *pBlob, unsigned int newSize){
489
+ if(newSize>pBlob->nUsed){
490
+ pBlob->xRealloc(pBlob, newSize);
491
+ pBlob->aData[newSize] = 0;
492
+ }
493
+}
482494
483495
/*
484496
** Make sure a blob is nul-terminated and is not a pointer to unmanaged
485497
** space. Return a pointer to the data.
486498
*/
487499
--- src/blob.c
+++ src/blob.c
@@ -477,10 +477,22 @@
477 void blob_resize(Blob *pBlob, unsigned int newSize){
478 pBlob->xRealloc(pBlob, newSize+1);
479 pBlob->nUsed = newSize;
480 pBlob->aData[newSize] = 0;
481 }
 
 
 
 
 
 
 
 
 
 
 
 
482
483 /*
484 ** Make sure a blob is nul-terminated and is not a pointer to unmanaged
485 ** space. Return a pointer to the data.
486 */
487
--- src/blob.c
+++ src/blob.c
@@ -477,10 +477,22 @@
477 void blob_resize(Blob *pBlob, unsigned int newSize){
478 pBlob->xRealloc(pBlob, newSize+1);
479 pBlob->nUsed = newSize;
480 pBlob->aData[newSize] = 0;
481 }
482
483 /*
484 ** Ensures that the given blob has at least the given amount of memory
485 ** allocated to it. Does not modify pBlob->nUsed nor will it reduce
486 ** the currently-allocated amount of memory.
487 */
488 void blob_reserve(Blob *pBlob, unsigned int newSize){
489 if(newSize>pBlob->nUsed){
490 pBlob->xRealloc(pBlob, newSize);
491 pBlob->aData[newSize] = 0;
492 }
493 }
494
495 /*
496 ** Make sure a blob is nul-terminated and is not a pointer to unmanaged
497 ** space. Return a pointer to the data.
498 */
499

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button