OSSP CVS Repository

ossp - Difference in ossp-pkg/sa/sa.c versions 1.25 and 1.26
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sa/sa.c 1.25 -> 1.26

--- sa.c 2001/10/09 20:19:58     1.25
+++ sa.c 2001/10/10 07:42:26     1.26
@@ -1005,7 +1005,7 @@
 }
 
 /* configure I/O buffers */
-sa_rc_t sa_buffers(sa_t *sa, size_t rsize, size_t wsize)
+sa_rc_t sa_buffer(sa_t *sa, sa_buffer_t id, size_t size)
 {
     char *cp;
 
@@ -1013,45 +1013,49 @@
     if (sa == NULL)
         return SA_ERR_ARG;
 
-    /* make sure buffered were already flushed sufficiently */
-    if (sa->nReadLen > rsize || sa->nWriteLen > wsize)
-        return SA_ERR_USE;
-
-    /* configure read/incoming buffer */
-    if (rsize > 0) {
-        if (sa->cpReadBuf == NULL)
-            cp = (char *)malloc(rsize);
-        else
-            cp = (char *)realloc(sa->cpReadBuf, rsize);
-        if (cp == NULL)
-            return SA_ERR_SYS;
-        sa->cpReadBuf = cp;
-        sa->nReadSize = rsize;
-    }
-    else {
-        if (sa->cpReadBuf != NULL)
-            free(sa->cpReadBuf);
-        sa->cpReadBuf = NULL;
-        sa->nReadSize = 0;
+    if (id == SA_BUFFER_READ) {
+        /* configure read/incoming buffer */
+        if (sa->nReadLen > size)
+            return SA_ERR_USE;
+        if (size > 0) {
+            if (sa->cpReadBuf == NULL)
+                cp = (char *)malloc(size);
+            else
+                cp = (char *)realloc(sa->cpReadBuf, size);
+            if (cp == NULL)
+                return SA_ERR_SYS;
+            sa->cpReadBuf = cp;
+            sa->nReadSize = size;
+        }
+        else {
+            if (sa->cpReadBuf != NULL)
+                free(sa->cpReadBuf);
+            sa->cpReadBuf = NULL;
+            sa->nReadSize = 0;
+        }
     }
-
-    /* configure write/outgoing buffer */
-    if (wsize > 0) {
-        if (sa->cpWriteBuf == NULL)
-            cp = (char *)malloc(wsize);
-        else
-            cp = (char *)realloc(sa->cpWriteBuf, wsize);
-        if (cp == NULL)
-            return SA_ERR_SYS;
-        sa->cpWriteBuf = cp;
-        sa->nWriteSize = wsize;
-    }
-    else {
-        if (sa->cpWriteBuf != NULL)
-            free(sa->cpWriteBuf);
-        sa->cpWriteBuf = NULL;
-        sa->nWriteSize = 0;
+    else if (id == SA_BUFFER_WRITE) {
+        /* configure write/outgoing buffer */
+        if (sa->nWriteLen > size)
+            return SA_ERR_USE;
+        if (size > 0) {
+            if (sa->cpWriteBuf == NULL)
+                cp = (char *)malloc(size);
+            else
+                cp = (char *)realloc(sa->cpWriteBuf, size);
+            if (cp == NULL)
+                return SA_ERR_SYS;
+            sa->cpWriteBuf = cp;
+            sa->nWriteSize = size;
+        }
+        else {
+            if (sa->cpWriteBuf != NULL)
+                free(sa->cpWriteBuf);
+            sa->cpWriteBuf = NULL;
+            sa->nWriteSize = 0;
+        }
     }
+        return SA_ERR_ARG;
 
     return SA_OK;
 }

CVSTrac 2.0.1