OSSP CVS Repository

ossp - Difference in ossp-pkg/xds/xdr-encode-uint64.c versions 1.3 and 1.3.2.1
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/xds/xdr-encode-uint64.c 1.3 -> 1.3.2.1

--- xdr-encode-uint64.c  2001/07/23 15:33:42     1.3
+++ xdr-encode-uint64.c  2001/08/01 11:26:56     1.3.2.1
@@ -28,33 +28,41 @@
 #include <assert.h>
 #include "internal.h"
 
-int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_uint64(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
+    xds_uint64_t value;
+
     /* Consistency checks. */
 
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(buffer_size != 0);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
+    xds_check_parameter(xds != NULL);
+    xds_check_parameter(buffer != NULL);
+    xds_check_parameter(buffer_size != 0);
+    xds_check_parameter(used_buffer_size != NULL);
+    xds_check_parameter(args != NULL);
+
+    /* We need 8 bytes in the buffer to format our parameter. If we
+       don't have them, return an overflow error. */
+
+    if (buffer_size < 8)
+        return XDS_ERR_OVERFLOW;
+    else
+        *used_buffer_size = 8;
 
     /* Get value and format it into the buffer. */
 
-    if (buffer_size >= 8)
-        {
-        xds_uint64_t value = va_arg(*args, xds_uint64_t);
-        ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[6] = (value >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[7] = (value >>  0) & 0x000000ff;
-        }
+    value = va_arg(*args, xds_uint64_t);
+    ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[6] = (value >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[7] = (value >>  0) & 0x000000ff;
 
     /* Done. */
 
-    return 8;
+    return XDS_OK;
     }

CVSTrac 2.0.1