ossp-pkg/rc/rc_config.c 1.41 -> 1.42
--- rc_config.c 2003/07/11 09:38:29 1.41
+++ rc_config.c 2003/07/11 14:13:16 1.42
@@ -40,31 +40,36 @@
#include "rc_version.c"
#undef _RC_VERSION_C_AS_HEADER_
-static int m_nLocks = 0; /* Server locks, not thread-safe FIXME */
+static int m_nLocks = 0; /* Server locks, not thread-safe FIXME */
/***************************************
* configNew(void) *
* Construct a configuration *
***************************************/
-rc_return_t configNew(void)
+rc_config_t configNew(void)
{
ex_t Except;
+ rc_config_t *pRetobj = NULL;
- if (m_nLocks == 0) { /* If we don't have one yet */
- try { /* then construct a new one */
- clioptNew(); /* Member cliopt instance */
+ if (m_nLocks == 0) { /* If we don't have one yet */
+ pRetobj = malloc(sizeof (rc_config_t)); /* then construct a new one */
+ if (pRetobj) {
+ try {
+ pRetobj->m_pCliopts = clioptNew(); /* Member cliopt instance */
+ }
+ catch(Except)
+ rethrow;
}
- catch(Except)
- rethrow;
+ else
+ RC_THROW(RC_ERR_MEM);
}
m_nLocks++; /* FIXME not threadsafe */
+ return(pRetobj);
/* Warn: Experimental design pattern code abstracts operations from config */
/* configVisit(pfnSetdefaults);
configVisit(pfnGetoptinfo);*/
-
- return(RC_THROW(RC_OK));
}
/* FIXME: Make into configVisit, using callbacks to get and set option info */
@@ -375,16 +380,16 @@
}
/***************************************
-* configDelete(void) *
+* configDelete(rc_config_t *) *
* Destruct a configuration *
***************************************/
-rc_return_t configDelete(void)
+rc_return_t configDelete(rc_config_t *this)
{
ex_t Except;
if (--m_nLocks == 0) { /* If m_nLocks is 0, deallocate */
try { /* FIXME, not thread-safe */
- clioptDelete();
+ clioptDelete(this->m_pCliopts);
}
catch(Except)
rethrow;
|
|