size_t-fy crypto/buffer.
[openssl.git] / crypto / buffer / buffer.c
index 03ebf23a14a03ef8145c07bc4887f7ff5f1c16d8..620ea8d5368a678c644696c0c7f650ea9ed8c085 100644 (file)
@@ -89,10 +89,10 @@ void BUF_MEM_free(BUF_MEM *a)
        OPENSSL_free(a);
        }
 
-int BUF_MEM_grow(BUF_MEM *str, int len)
+int BUF_MEM_grow(BUF_MEM *str, size_t len)
        {
        char *ret;
-       unsigned int n;
+       size_t n;
 
        if (str->length >= len)
                {
@@ -125,10 +125,10 @@ int BUF_MEM_grow(BUF_MEM *str, int len)
        return(len);
        }
 
-int BUF_MEM_grow_clean(BUF_MEM *str, int len)
+int BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
        {
        char *ret;
-       unsigned int n;
+       size_t n;
 
        if (str->length >= len)
                {
@@ -149,7 +149,7 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len)
                ret=OPENSSL_realloc_clean(str->data,str->max,n);
        if (ret == NULL)
                {
-               BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
+               BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE);
                len=0;
                }
        else
@@ -219,3 +219,26 @@ size_t BUF_strlcat(char *dst, const char *src, size_t size)
                l++;
        return l + BUF_strlcpy(dst, src, size);
        }
+
+void BUF_reverse(unsigned char *out, unsigned char *in, size_t size)
+       {
+       size_t i;
+       if (in)
+               {
+               out += size - 1;
+               for (i = 0; i < size; i++)
+                       *in++ = *out--;
+               }
+       else
+               {
+               unsigned char *q;
+               char c;
+               q = out + size - 1;
+               for (i = 0; i < size/2; i++)
+                       {
+                       c = *q;
+                       *q-- = *out;
+                       *out++ = c;
+                       }
+               }
+       }