Index: trunk/psLib/src/sysUtils/psErrorCodes.c
===================================================================
--- trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 1905)
+++ trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 2129)
@@ -7,9 +7,11 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:38:02 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
+
+#include <string.h>
 
 #include "psError.h"
@@ -75,12 +77,34 @@
         desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD);
         while (desc != NULL) {
-            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
-            if (desc != NULL && desc->code == code) {
+            if (desc->code == code) {
                 return desc;
             }
+            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
         }
     }
     return NULL;
 }
+
+static void freeErrorDescription(psErrorDescription* err)
+{
+    psFree((void*)err->description);
+}
+
+psErrorDescription* psErrorDescriptionAlloc(psErrorCode code,
+        const char *description)
+{
+    psErrorDescription* err = psAlloc(sizeof(psErrorDescription));
+    err->code = code;
+    if (description == NULL) {
+        err->description = NULL;
+    } else {
+        err->description = psAlloc(sizeof(char)*strlen(description)+1);
+        strcpy((char*)err->description,description);
+    }
+
+    p_psMemSetDeallocator(err,(psFreeFcn)freeErrorDescription);
+    return err;
+}
+
 
 const char *psErrorCodeString(psErrorCode code)
@@ -114,8 +138,17 @@
     }
 
+    if (dynamicErrorCodes == NULL) {
+        dynamicErrorCodes = psListAlloc(NULL);
+        p_psMemSetPersistent(dynamicErrorCodes,true);
+    }
+
     for (int i=0;i<nerror;i++) {
+        psErrorDescription* err = psErrorDescriptionAlloc(
+                                      errors[i].code, errors[i].description);
+        p_psMemSetPersistent(err,true);
+        p_psMemSetPersistent((void*)err->description,true);
         if (! psListAdd(dynamicErrorCodes,
                         PS_LIST_HEAD,
-                        (void*)&errors[i]) ) {
+                        err) ) {
 
             psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
@@ -124,5 +157,26 @@
                        i);
         }
+        p_psMemSetPersistent(dynamicErrorCodes->head,true);
+        psFree(err);
     }
 }
 
+bool p_psErrorUnregister(psErrorCode code)
+{
+    // Check input argument is non-negative
+    if ( code < 0 ) {
+        return false;
+    }
+
+    const psErrorDescription* desc = getErrorDescription(code);
+
+    if (desc == NULL) {
+        return false;
+    }
+
+    if (dynamicErrorCodes == NULL) {
+        return false;
+    }
+
+    return psListRemove(dynamicErrorCodes,PS_LIST_UNKNOWN,(void*)desc);
+}
