mirror of https://github.com/aria2/aria2
2007-12-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed unnecessary string copy. Updated doc and corrected indentation. * src/Base64.cc * Release 0.12.0pull/1/head
parent
059406ae50
commit
2fe11ac548
|
@ -1,5 +1,8 @@
|
|||
2007-12-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Removed unnecessary string copy. Updated doc and corrected indentation.
|
||||
* src/Base64.cc
|
||||
|
||||
* Release 0.12.0
|
||||
|
||||
2007-12-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
|
|
@ -65,7 +65,7 @@ static const int INDEX_TABLE[] = {
|
|||
};
|
||||
|
||||
void Base64::encode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength)
|
||||
const unsigned char* src, size_t slength)
|
||||
{
|
||||
if(slength == 0) {
|
||||
rlength = 0;
|
||||
|
@ -105,9 +105,9 @@ void Base64::encode(unsigned char*& result, size_t& rlength,
|
|||
}
|
||||
|
||||
void Base64::removeNonBase64Chars(unsigned char*& nsrc,
|
||||
size_t& nlength,
|
||||
const unsigned char* src,
|
||||
size_t slength)
|
||||
size_t& nlength,
|
||||
const unsigned char* src,
|
||||
size_t slength)
|
||||
{
|
||||
unsigned char* temp = new unsigned char[slength];
|
||||
const unsigned char* end = src+slength;
|
||||
|
@ -117,15 +117,12 @@ void Base64::removeNonBase64Chars(unsigned char*& nsrc,
|
|||
*(temp+n++) = *s;
|
||||
}
|
||||
}
|
||||
unsigned char* ret = new unsigned char[n];
|
||||
memcpy(ret, temp, n);
|
||||
delete [] temp;
|
||||
nlength = n;
|
||||
nsrc = ret;
|
||||
nsrc = temp;
|
||||
}
|
||||
|
||||
void Base64::decode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength)
|
||||
const unsigned char* src, size_t slength)
|
||||
{
|
||||
if(slength == 0) {
|
||||
rlength = 0;
|
||||
|
|
|
@ -41,6 +41,11 @@ using namespace std;
|
|||
class Base64
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Removes non base64 chars(including '=') from src, and results are
|
||||
* stored in nsrc and its length is stored in nlength.
|
||||
* Caller must delete nsrc.
|
||||
*/
|
||||
static void removeNonBase64Chars(unsigned char*& nsrc, size_t& nlength,
|
||||
const unsigned char* src, size_t slength);
|
||||
|
||||
|
|
Loading…
Reference in New Issue