diff base64.c @ 320:ca1f5d65e653 libavutil

expose av_base64_decode and av_base64_encode
author lu_zero
date Mon, 19 Mar 2007 00:48:47 +0000
parents 9a977b2c7069
children 62575220eb1a
line wrap: on
line diff
--- a/base64.c	Wed Mar 14 19:47:58 2007 +0000
+++ b/base64.c	Mon Mar 19 00:48:47 2007 +0000
@@ -70,7 +70,7 @@
 * fixed edge cases and made it work from data (vs. strings) by ryan.
 *****************************************************************************/
 
-char *av_base64_encode(uint8_t * src, int len)
+char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len)
 {
     static const char b64[] =
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -79,11 +79,10 @@
     int i_shift = 0;
     int bytes_remaining = len;
 
-    if (len < UINT_MAX / 4) {
-        ret = dst = av_malloc(len * 4 / 3 + 12);
-    } else
+    if (len >= UINT_MAX / 4 ||
+        buf_len < len * 4 / 3 + 12)
         return NULL;
-
+    ret = dst = buf;
     if (len) {                  // special edge case, what should we really do here?
         while (bytes_remaining) {
             i_bits = (i_bits << 8) + *src++;