ossp-pkg/rc/rc_cliopt.c 1.9 -> 1.10
--- rc_cliopt.c 2002/05/22 13:29:40 1.9
+++ rc_cliopt.c 2002/05/23 18:03:20 1.10
@@ -169,24 +169,17 @@
rc_return_t clioptSetsecs(const char **pkszSecs)
{
- int nSecs = 0;
- int nIndex = 0;
+ ex_t Except;
- if (m_pszSecs) /* Warn on overwrites */
+ if (m_pszSecs) /* Warn on overwrites */
RC_THROW(RC_WRN_OWR);
- if (pkszSecs) {
- for (nSecs = 0; pkszSecs[nSecs]; nSecs++); /* Count the sections */
- m_pszSecs = malloc(sizeof (char **) * nSecs + 1);
-
- for (nIndex = 0; pkszSecs[nIndex]; nIndex++) {
- m_pszSecs[nIndex] = malloc(strlen(pkszSecs[nIndex]));
- memcpy(m_pszSecs[nIndex], pkszSecs[nIndex],\
- strlen(pkszSecs[nIndex]));
- }
- m_pszSecs[nIndex] = NULL; /* Used later to find the end of the array */
+
+ ex_try {
+ m_pszSecs = vectorCopy(pkszSecs);
+ }
+ ex_catch(Except) {
+ rethrow;
}
- else
- return(RC_THROW(RC_ERR_USE)); /* Incoming sections are NULL? */
return(RC_THROW(RC_OK));
}
@@ -359,13 +352,9 @@
if (m_szRcfile) /* Free the rc file arg */
free(m_szRcfile);
- if (m_pszSecs) { /* Free the section name arg */
- for (i = 0; m_pszSecs[i]; i++) {
- free(m_pszSecs[i]);
- m_pszSecs[i] = NULL;
- }
- free(m_pszSecs);
- }
+
+ if (m_pszSecs) /* Free the section name arg */
+ vectorDel(m_pszSecs);
/* FIXME BEGIN DEBUG */
for (i = 0; i < RC_NUMOPTS; i++)
|
|