smal fixes
This commit is contained in:
parent
b3f67a38de
commit
14ffede476
@ -20,4 +20,4 @@ u32 base64_decodedSize(const char* src, u32 src_size);
|
||||
/// @param src_size size of data to decode. Must be a multiple of 4 for valid base64 data.
|
||||
/// @param dst buffer of size base64_decodedSize(src, src_size)
|
||||
/// @return number of decoded characters or 0 on error
|
||||
u32 base64_decode(const u8* src, u32 src_size, u8* dst);
|
||||
u32 base64_decode(const char* src, u32 src_size, u8* dst);
|
||||
|
||||
@ -35,6 +35,3 @@ static inline Array_ Array_copy(Array_ src){
|
||||
|
||||
#define Array_len(AR, T) ((AR)->size / sizeof(T))
|
||||
#define Array_memset(A, VAL) memset((A)->data, VAL, (A)->size)
|
||||
|
||||
#define str_castTo_Array(S) Array_construct_size((S).data, (S).size)
|
||||
#define Array_castTo_str(S, IS_ZERO_TERMINATED) str_construct((S).data, (S).size, IS_ZERO_TERMINATED)
|
||||
|
||||
@ -20,6 +20,14 @@ static inline str str_from_cstr(cstr s_ptr){
|
||||
return str_construct((void*)s_ptr, strlen(s_ptr), true);
|
||||
}
|
||||
|
||||
static inline Array_ str_castTo_Array(str s) {
|
||||
return Array_construct_size(s.data, s.size);
|
||||
}
|
||||
|
||||
static inline str Array_castTo_str(Array_ a, bool isZeroTerminated) {
|
||||
return str_construct(a.data, a.size, isZeroTerminated);
|
||||
}
|
||||
|
||||
static const str str_null = str_construct(NULL, 0, 0);
|
||||
|
||||
/// copies src content to new string and adds \0 at the end
|
||||
|
||||
@ -61,7 +61,7 @@ static int b64inverse[] = {
|
||||
43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||
};
|
||||
|
||||
u32 base64_decode(const u8* src, u32 src_size, u8* dst){
|
||||
u32 base64_decode(const char* src, u32 src_size, u8* dst){
|
||||
// incomplete src
|
||||
if(src_size % 4 != 0)
|
||||
return 0;
|
||||
|
||||
@ -6,7 +6,8 @@ void StringBuilder_destroy(StringBuilder* b){
|
||||
}
|
||||
|
||||
str StringBuilder_getStr(StringBuilder* b){
|
||||
List_push(&b->buffer, u8, '\0');
|
||||
if(b->buffer.size == 0 || ((char*)b->buffer.data)[b->buffer.size - 1] != '\0')
|
||||
List_push(&b->buffer, u8, '\0');
|
||||
str result = str_construct((char*)b->buffer.data, b->buffer.size - 1, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user