Skip to content

Commit

Permalink
utils: move base64 length compute to macros
Browse files Browse the repository at this point in the history
This allows us to initialize data for static variables, such as uuid
  • Loading branch information
razvancrainea committed Sep 28, 2017
1 parent f0d2a87 commit 16f6e6b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ut.h
Expand Up @@ -1073,17 +1073,10 @@ int base64decode(unsigned char *out,unsigned char *in,int len);
void word64encode(unsigned char *out, unsigned char *in, int inlen);
int word64decode(unsigned char *out, unsigned char *in, int len);

static inline int calc_base64_encode_len(int len)
{
return (len/3 + (len%3?1:0))*4;
}
#define calc_word64_encode_len calc_base64_encode_len

static inline int calc_max_base64_decode_len(int len)
{
return len*3/4;
}
#define calc_base64_encode_len(_l) (((_l)/3 + ((_l)%3?1:0))*4)
#define calc_max_base64_decode_len(_l) ((_l)*3/4)

#define calc_word64_encode_len calc_base64_encode_len
#define calc_max_word64_decode_len calc_max_base64_decode_len


Expand Down

0 comments on commit 16f6e6b

Please sign in to comment.