There's no need to dynamically allocate encode_string, so just make it static. It does need to be unsigned char though, for the loop that intialises it. So cast it when calling my_encrypt() / my_decrypt().