OSSP CVS Repository

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

ossp-pkg/l2/l2_env.c 1.1 -> 1.2

--- l2_env.c     2001/11/04 13:21:17     1.1
+++ l2_env.c     2001/11/04 13:55:06     1.2
@@ -24,30 +24,36 @@
 **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 **  SUCH DAMAGE.
 **
-**  l2_env.c: environment
-**
+**  l2_env.c: environment object
 */
 
-#include "l2.h"
 #include "l2_p.h"
 
 /* create environment object */
-l2_result_t l2_env_create(l2_env_t **env)
+l2_result_t l2_env_create(l2_env_t **envp)
 {
+    l2_env_t *env;
     int i;
+
+    /* argument sanity check */
+    if (envp == NULL)
+        return L2_ERR_ARG;
     
-    /* allocate env structure */ 
-    if (((*env) = (l2_env_t *)malloc(sizeof(l2_env_t))) == NULL)
+    /* allocate environment structure */ 
+    if ((env = (l2_env_t *)malloc(sizeof(l2_env_t))) == NULL)
         return L2_ERR_SYS;
 
-    /* initialize env structure */
-    (*env)->rvErrorInfo = L2_OK;
-    (*env)->szErrorInfo[0] = '\0';
-    (*env)->szError[0] = '\0';
-    (*env)->levelmask = L2_LEVEL_ALL;
-    (*env)->flushmask = L2_LEVEL_NONE;
+    /* initialize environment structure */
+    env->rvErrorInfo = L2_OK;
+    env->szErrorInfo[0] = '\0';
+    env->szError[0] = '\0';
+    env->levelmask = L2_LEVEL_ALL;
+    env->flushmask = L2_LEVEL_NONE;
     for (i = 0; i < L2_MAX_FORMATTERS; i++)
-        (*env)->formatters[i].cb = NULL;
+        env->formatters[i].cb = NULL;
+
+    /* pass new object to caller */
+    (*envp) = env;
 
     return L2_OK;
 }
@@ -96,13 +102,14 @@
         return L2_ERR_MEM;
 
     /* attach formatter to env */
-    env->formatters[i].id   = id;
-    env->formatters[i].ctx  = ctx;
-    env->formatters[i].cb   = cb;
+    env->formatters[i].id  = id;
+    env->formatters[i].ctx = ctx;
+    env->formatters[i].cb  = cb;
 
     return L2_OK;
 }
 
+/* remember additional error information */
 l2_result_t l2_env_errorinfo(l2_env_t *env, l2_result_t rv, const char *fmt, ...)
 {
     va_list ap;
@@ -120,6 +127,7 @@
     return L2_OK;
 }
 
+/* retrieve string description of error result code */
 char *l2_env_strerror(l2_env_t *env, l2_result_t rv)
 {
     char *sz;

CVSTrac 2.0.1