OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_lab.c versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_lab.c 1.1 -> 1.2

--- rc_lab.c     2003/05/20 11:45:11     1.1
+++ rc_lab.c     2003/05/20 15:06:41     1.2
@@ -60,15 +60,35 @@
 rc_return_t labelAppendsec(rc_label_t *pLabel, rc_section_t *pInsec)
 {
     assert(pLabel); /* Label parameter must be valid */
+    if (!pInsec)    /* Check sanity */
+        return(RC_THROW(RC_ERR_USE));
 
-    if (pInsec) {
-        pLabel->m_ppSecvec = realloc(pLabel->m_ppSecvec, sizeof(rc_section_t *)\
-            * (pLabel->m_nSecs + 1));
-        pLabel->m_ppSecvec[pLabel->m_nSecs++] = pInsec; /* Just copy pointer */
+    /* First make our vector larger to hold one more section */
+    pLabel->m_ppSecvec = realloc(pLabel->m_ppSecvec, sizeof(rc_section_t *)\
+        * (pLabel->m_nSecs + 1));
+    pLabel->m_ppSecvec[pLabel->m_nSecs] = sectionNew(pInsec->m_szName);
+
+    /* Simple value copy */
+    pLabel->m_ppSecvec[pLabel->m_nSecs]->m_nPri  = pInsec->m_nPri;
+    pLabel->m_ppSecvec[pLabel->m_nSecs]->m_nUid  = pInsec->m_nUid;
+    pLabel->m_ppSecvec[pLabel->m_nSecs]->m_Bytes = pInsec->m_Bytes;
+
+    /* Deep copy of user name */
+    if (pInsec->m_szLogin) {
+        pLabel->m_ppSecvec[pLabel->m_nSecs]->m_szLogin =\
+            malloc((strlen(pInsec->m_szLogin) + sizeof(char)) * sizeof(char));
+        strcpy(pLabel->m_ppSecvec[pLabel->m_nSecs]->m_szLogin, pInsec->m_szLogin);
     }
-    else
-        TRACE("Problem with labelAppendsec");
-/*        return(RC_THROW(RC_ERR_USE));*/
+
+    /* Deep copy of section text */
+    if (pInsec->m_szData) {
+        pLabel->m_ppSecvec[pLabel->m_nSecs]->m_szData =\
+            malloc((strlen(pInsec->m_szData) + sizeof(char)) * sizeof(char));
+        strcpy(pLabel->m_ppSecvec[pLabel->m_nSecs]->m_szData, pInsec->m_szData);
+    }
+
+    /* Finally increment section count */
+    pLabel->m_nSecs++;
 
     return(RC_THROW(RC_OK));
 }

CVSTrac 2.0.1