OSSP CVS Repository

ossp - Check-in [4150]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4150
Date: 2001-Jul-04 18:21:26 (local)
2001-Jul-04 16:21:26 (UTC)
User:simons
Branch:
Comment: Added preliminary implementations for xds_init() and xds_destroy().
Tickets:
Inspections:
Files:
ossp-pkg/xds/destroy.c      1.1 -> 1.2     8 inserted, 0 deleted
ossp-pkg/xds/init.c      1.1 -> 1.2     26 inserted, 2 deleted

ossp-pkg/xds/destroy.c 1.1 -> 1.2

--- destroy.c    2001/07/04 15:58:51     1.1
+++ destroy.c    2001/07/04 16:21:26     1.2
@@ -25,8 +25,16 @@
    SUCH DAMAGE.
 */
 
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
 #include "internal.h"
 
 void xds_destroy(xds_t* xds)
     {
+    assert(xds != NULL);
+    if (xds != NULL)
+        {
+        free(xds);
+        }
     }


ossp-pkg/xds/init.c 1.1 -> 1.2

--- init.c       2001/07/04 15:58:51     1.1
+++ init.c       2001/07/04 16:21:26     1.2
@@ -26,10 +26,34 @@
 */
 
 #include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
 #include "internal.h"
 
 xds_t* xds_init(xds_mode_t mode)
     {
-    xds_t* ctx = calloc(1, sizeof(struct xds_context));
-    return NULL;
+    xds_t* ctx;
+
+    /* Sanity check parameter. */
+
+    assert(mode == XDS_ENCODE || mode == XDS_DECODE);
+    if (mode != XDS_ENCODE && mode != XDS_DECODE)
+        {
+        errno = EINVAL;
+        return NULL;
+        }
+
+    /* Allocate context structure. */
+
+    ctx = calloc(1, sizeof(struct xds_context));
+    if (ctx == NULL)
+        return NULL;            /* errno is set by calloc() */
+
+    /* Set mode of operation in context. */
+
+    ctx->mode = mode;
+
+    /* We are initialized. */
+
+    return ctx;
     }

CVSTrac 2.0.1