Prefer new over malloc
The former cannot return NULL and will allow use of scoped pointers.
This commit is contained in:
@ -372,9 +372,7 @@ char* s3fs_base64(const unsigned char* input, size_t length)
|
||||
if(!input || 0 == length){
|
||||
return NULL;
|
||||
}
|
||||
if(NULL == (result = reinterpret_cast<char*>(malloc((((length / 3) + 1) * 4 + 1) * sizeof(char))))){
|
||||
return NULL; // ENOMEM
|
||||
}
|
||||
result = new char[((length / 3) + 1) * 4 + 1];
|
||||
|
||||
unsigned char parts[4];
|
||||
size_t rpos;
|
||||
@ -422,9 +420,7 @@ unsigned char* s3fs_decode64(const char* input, size_t* plength)
|
||||
if(!input || 0 == strlen(input) || !plength){
|
||||
return NULL;
|
||||
}
|
||||
if(NULL == (result = reinterpret_cast<unsigned char*>(malloc((strlen(input) + 1))))){
|
||||
return NULL; // ENOMEM
|
||||
}
|
||||
result = new unsigned char[strlen(input) + 1];
|
||||
|
||||
unsigned char parts[4];
|
||||
size_t input_len = strlen(input);
|
||||
|
||||
Reference in New Issue
Block a user