diff options
author | Mike Buland <eichlan@xagasoft.com> | 2022-04-15 08:46:54 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2022-04-15 08:46:54 -0700 |
commit | 6e3124d6aec9d4ad9fbe92beec82add5e1a811fe (patch) | |
tree | 80f7453fa7ff35cec10736bad7f5b304c5d4b929 /src | |
parent | 1c4372bbff3e5978b19bd25cf1310078d0977d08 (diff) | |
download | libbu++-6e3124d6aec9d4ad9fbe92beec82add5e1a811fe.tar.gz libbu++-6e3124d6aec9d4ad9fbe92beec82add5e1a811fe.tar.bz2 libbu++-6e3124d6aec9d4ad9fbe92beec82add5e1a811fe.tar.xz libbu++-6e3124d6aec9d4ad9fbe92beec82add5e1a811fe.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/unstable/blob.cpp | 3 | ||||
-rw-r--r-- | src/unstable/blobbuilder.cpp | 13 | ||||
-rw-r--r-- | src/unstable/blobbuilder.h | 1 |
3 files changed, 16 insertions, 1 deletions
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 ) : | |||
31 | iSize( 0 ) | 31 | iSize( 0 ) |
32 | { | 32 | { |
33 | iSize = rSrc.getSize(); | 33 | iSize = rSrc.getSize(); |
34 | pData = new char[iSize]; | 34 | pData = new char[iSize+1]; |
35 | 35 | ||
36 | rSrc.copyTo( pData, iSize ); | 36 | rSrc.copyTo( pData, iSize ); |
37 | pData[iSize] = '\0'; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | Bu::Blob::Blob( const char *pSrc ) : | 40 | 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() : | |||
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | Bu::BlobBuilderCore::BlobBuilderCore( const Bu::Blob &rSrc ) : | ||
92 | pFirst( 0 ), | ||
93 | pLast( 0 ), | ||
94 | iLength( 0 ) | ||
95 | { | ||
96 | append( rSrc.getData(), rSrc.getSize() ); | ||
97 | } | ||
98 | |||
91 | Bu::BlobBuilderCore::BlobBuilderCore( const Bu::BlobBuilderCore &rSrc ) : | 99 | Bu::BlobBuilderCore::BlobBuilderCore( const Bu::BlobBuilderCore &rSrc ) : |
92 | pFirst( 0 ), | 100 | pFirst( 0 ), |
93 | pLast( 0 ), | 101 | pLast( 0 ), |
@@ -239,6 +247,11 @@ Bu::BlobBuilder::BlobBuilder() | |||
239 | { | 247 | { |
240 | } | 248 | } |
241 | 249 | ||
250 | Bu::BlobBuilder::BlobBuilder( const Bu::Blob &rSrc ) | ||
251 | { | ||
252 | append( rSrc ); | ||
253 | } | ||
254 | |||
242 | Bu::BlobBuilder::BlobBuilder( const Bu::BlobBuilder &rSrc ) : | 255 | Bu::BlobBuilder::BlobBuilder( const Bu::BlobBuilder &rSrc ) : |
243 | Bu::SharedCore<Bu::BlobBuilder, Bu::BlobBuilderCore>( rSrc ) | 256 | Bu::SharedCore<Bu::BlobBuilder, Bu::BlobBuilderCore>( rSrc ) |
244 | { | 257 | { |
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 | |||
45 | }; | 45 | }; |
46 | 46 | ||
47 | BlobBuilderCore(); | 47 | BlobBuilderCore(); |
48 | BlobBuilderCore( const Bu::Blob &rSrc ); | ||
48 | BlobBuilderCore( const BlobBuilderCore &rSrc ); | 49 | BlobBuilderCore( const BlobBuilderCore &rSrc ); |
49 | virtual ~BlobBuilderCore(); | 50 | virtual ~BlobBuilderCore(); |
50 | 51 | ||