ossp-pkg/xds/getbuffer.c 1.1 -> 1.2
--- getbuffer.c 2001/07/04 15:58:51 1.1
+++ getbuffer.c 2001/07/09 17:22:03 1.2
@@ -25,9 +25,31 @@
SUCH DAMAGE.
*/
+#include "assert.h"
#include "internal.h"
-int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_size)
+int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_len)
{
- return XDS_ERR_INVALID_ARG;
+ /* Sanity checks. */
+
+ assert(xds != NULL);
+ assert(flag == XDS_GIFT || flag == XDS_LOAN);
+ assert(buffer != NULL);
+ assert(buffer_len != NULL);
+ if (xds == NULL || buffer == NULL || buffer_len == NULL || (flag != XDS_GIFT && flag != XDS_LOAN))
+ return XDS_ERR_INVALID_ARG;
+
+ /* Return the buffer to the caller. */
+
+ *buffer = xds->buffer;
+ *buffer_len = xds->buffer_len;
+ if (flag == XDS_GIFT)
+ {
+ xds->buffer = NULL;
+ xds->buffer_capacity = xds->buffer_len = 0;
+ }
+ else
+ xds->buffer_len = 0;
+
+ return XDS_OK;
}
|
|