From 6e3124d6aec9d4ad9fbe92beec82add5e1a811fe Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 15 Apr 2022 08:46:54 -0700 Subject: Augments to Blob and BlobBuilder. You can construct a BlobBuilder from a Blob now, and Blob has an extra null byte of padding just in case you use a Blob to store a string. --- src/unstable/blob.cpp | 3 ++- src/unstable/blobbuilder.cpp | 13 +++++++++++++ src/unstable/blobbuilder.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/unstable/blob.cpp b/src/unstable/blob.cpp index 69ec28f..e72e265 100644 --- a/src/unstable/blob.cpp +++ b/src/unstable/blob.cpp @@ -31,9 +31,10 @@ Bu::Blob::Blob( const class BlobBuilder &rSrc ) : iSize( 0 ) { iSize = rSrc.getSize(); - pData = new char[iSize]; + pData = new char[iSize+1]; rSrc.copyTo( pData, iSize ); + pData[iSize] = '\0'; } Bu::Blob::Blob( const char *pSrc ) : diff --git a/src/unstable/blobbuilder.cpp b/src/unstable/blobbuilder.cpp index fd62cb0..29646ba 100644 --- a/src/unstable/blobbuilder.cpp +++ b/src/unstable/blobbuilder.cpp @@ -88,6 +88,14 @@ Bu::BlobBuilderCore::BlobBuilderCore() : { } +Bu::BlobBuilderCore::BlobBuilderCore( const Bu::Blob &rSrc ) : + pFirst( 0 ), + pLast( 0 ), + iLength( 0 ) +{ + append( rSrc.getData(), rSrc.getSize() ); +} + Bu::BlobBuilderCore::BlobBuilderCore( const Bu::BlobBuilderCore &rSrc ) : pFirst( 0 ), pLast( 0 ), @@ -239,6 +247,11 @@ Bu::BlobBuilder::BlobBuilder() { } +Bu::BlobBuilder::BlobBuilder( const Bu::Blob &rSrc ) +{ + append( rSrc ); +} + Bu::BlobBuilder::BlobBuilder( const Bu::BlobBuilder &rSrc ) : Bu::SharedCore( rSrc ) { diff --git a/src/unstable/blobbuilder.h b/src/unstable/blobbuilder.h index c343a4f..c2995cb 100644 --- a/src/unstable/blobbuilder.h +++ b/src/unstable/blobbuilder.h @@ -45,6 +45,7 @@ namespace Bu }; BlobBuilderCore(); + BlobBuilderCore( const Bu::Blob &rSrc ); BlobBuilderCore( const BlobBuilderCore &rSrc ); virtual ~BlobBuilderCore(); -- cgit v1.2.3