[riot-notifications] [RIOT-OS/RIOT] sys/base64: Add size estimation functions (#10796)

danpetry notifications at github.com
Thu Jan 24 11:39:34 CET 2019


danpetry commented on this pull request.



> + */
+static inline size_t base64_estimate_decode_size(size_t base64_in_size)
+{
+    return ((base64_in_size / 4) * 3);
+}
+
+/**
+ * @brief Estimates the length of the resulting string after encoding
+ * @p data_in_size bytes into base64.
+ *
+ * @param[in] data_in_size Amount of bytes to be encoded
+ * @return Amount of characters the output string is estimated to have
+ */
+static inline size_t base64_estimate_encode_size(size_t data_in_size)
+{
+    return (4 * ((data_in_size + 2) / 3));

ok thanks!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10796#discussion_r250549869
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190124/ca0b73e7/attachment.html>


More information about the notifications mailing list