Index: /trunk/psLib/src/astro/psTime.c
===================================================================
--- /trunk/psLib/src/astro/psTime.c	(revision 11693)
+++ /trunk/psLib/src/astro/psTime.c	(revision 11694)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.109 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-06 21:36:09 $
+ *  @version $Revision: 1.110 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -899,5 +899,5 @@
 
         // Date too early for tables. Get default time delta value from metadata, and issue warning.
-        psLogMsg(__func__,PS_LOG_WARN,_("Specified psTime predates (%g) all tables of %s information."),mjd,"UT1-UTC");
+        psLogMsg("psLib.astro", PS_LOG_WARN,_("Specified psTime predates (%g) all tables of %s information."),mjd,"UT1-UTC");
 
         // Lookup value from time metadata loaded from pslib.config
@@ -919,5 +919,5 @@
         */
         // Generate warning of postdate information
-        psLogMsg(__func__,PS_LOG_WARN,_("Specified psTime postdates (%g) all tables of %s information."), mjd, "UT1-UTC");
+        psLogMsg("psLib.astro", PS_LOG_WARN,_("Specified psTime postdates (%g) all tables of %s information."), mjd, "UT1-UTC");
 
         // Lookup values to calculate prediction
@@ -1081,5 +1081,5 @@
         #else
 
-        psLogMsg(PS_FILE_LINE, PS_LOG_ERROR, _("Specified psTime predates (%g) all tables of %s information."), mjd, "polar motion");
+        psLogMsg("psLib.astro", PS_LOG_ERROR, _("Specified psTime predates (%g) all tables of %s information."), mjd, "polar motion");
         #endif
 
@@ -1116,5 +1116,5 @@
         #else
 
-        psLogMsg(PS_FILE_LINE, PS_LOG_ERROR,
+        psLogMsg("psLib.astro", PS_LOG_ERROR,
                  _("Specified psTime postdates (%g) all tables of %s information."), mjd, "polar motion");
         #endif
Index: /trunk/psLib/src/sys/psConfigure.h
===================================================================
--- /trunk/psLib/src/sys/psConfigure.h	(revision 11693)
+++ /trunk/psLib/src/sys/psConfigure.h	(revision 11694)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-23 22:47:23 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,4 +32,5 @@
     void
 );
+
 
 /** Get current psLib version (full identification)
@@ -53,4 +54,5 @@
 );
 
+
 /** Removes persistant memory created with the psLibInit function.
  *
@@ -64,7 +66,9 @@
 );
 
+
 // Check the memory; intended for use on exit, but might be used elsewhere
 void p_psMemoryCheck(void);
 
+
 /// @}
 #endif // #ifndef PS_CONFIGURE_H
Index: /trunk/psLib/src/sys/psError.h
===================================================================
--- /trunk/psLib/src/sys/psError.h	(revision 11693)
+++ /trunk/psLib/src/sys/psError.h	(revision 11694)
@@ -10,7 +10,8 @@
  *  @author RHL, Princeton
  *  @author Eric Van Alst, MHPCC
- *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-07 01:15:49 $
+ *  @author Joshua Hoblitt, University of Hawaii
+ *
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -55,4 +56,5 @@
 );
 
+
 /** Get last error put on the error stack
  *
@@ -64,4 +66,5 @@
 psErr* psErrorLast(void);
 
+
 /** Get errorCode of last error put on the error stack
  *
@@ -70,4 +73,5 @@
 psErrorCode psErrorCodeLast(void);
 
+
 /** Clears the error stack.
  *
@@ -77,4 +81,5 @@
 void psErrorClear(void);
 
+
 /** Get the error stack depth
  *
@@ -82,4 +87,5 @@
  */
 long psErrorGetStackSize();
+
 
 /** Prints error stack to specified open file descriptor
@@ -91,17 +97,13 @@
  *
  */
-#ifdef __GNUC__
 void psErrorStackPrint(
     FILE* fd,                          ///< destination file descriptor
     const char* format,                ///< printf-style format of header line
     ...                                ///< any parameters required in format
+#ifdef __GNUC__
 ) __attribute__((format(printf, 2, 3)));
-#else // __GNUC__
-void psErrorStackPrint(
-    FILE* fd,                          ///< destination file descriptor
-    const char* format,                ///< printf-style format of header line
-    ...                                ///< any parameters required in format
-);
-#endif // __GNUC__
+#else // ifdef __GNUC__
+);
+#endif // ifdef __GNUC__
 
 
@@ -120,7 +122,7 @@
     va_list va                         ///< any parameters required in format
 );
-#endif // #ifndef SWIG
-
-#ifdef DOXYGEN
+#endif // ifndef SWIG
+
+
 /** Reports an error message to the logging facility
  *
@@ -133,4 +135,5 @@
  *  @return psErrorCode    the given error code
  */
+#ifdef DOXYGEN
 psErrorCode psError(
     psErrorCode code,                  ///< Error class code
@@ -139,29 +142,5 @@
     ...                                ///< any parameters required in format
 );
-
-/** Logs a warning message.
- *
- *  This procedure logs a message to the destination set by a prior
- *  call to psLogSetDestination(), This is equivalent to calling
- *  psLogMsg with a level of PS_LOG_WARN.
- *
- */
-void psWarning(
-    const char* format,                ///< printf-style format of header line
-    ...                                ///< any parameters required in format
-);
-#else // #ifdef DOXYGEN
-
-/** Reports an error message to the logging facility
- *
- *  This function will invoke the psLogMsg function with a level of
- *  PS_LOG_ERROR and pass the parameters name and format to generate a proper
- *  log message.  This function is used to check a specific code location.
- *
- *  This function modifies the error stack.
- *
- *  @return psErrorcode    the given error code
- */
-#ifdef __GNUC__
+#else // ifdef DOXYGEN
 psErrorCode p_psError(
     const char* filename,              ///< file name
@@ -172,25 +151,29 @@
     const char* format,                ///< printf-style format of header line
     ...                                ///< any parameters required in format
+#ifdef __GNUC__
 ) __attribute__((format(printf, 6, 7)));
-#else // __GNUC__
-psErrorCode p_psError(
-    const char* filename,              ///< file name
-    unsigned int lineno,               ///< line number in file
-    const char* func,                  ///< function name
-    psErrorCode code,                  ///< Error class code
-    bool new,                          ///< true if error originates at this location
-    const char* format,                ///< printf-style format of header line
-    ...                                ///< any parameters required in format
-);
-#endif // __GNUC__
+#else // ifdef __GNUC__
+);
+#endif // ifdef __GNUC__
+#ifndef SWIG
+#define psError(code,new,...) \
+      p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Logs a warning message.
  *
- *  This procedure logs a message to the destination set by a prior call to
- *  psLogSetDestination().  This is equivalent to calling psLogMsg with a level of
- *  PS_LOG_WARN.  This function is used to check a specific code location.
- *
-*/
-#ifdef __GNUC__
+ *  This procedure logs a message to the destination set by a prior
+ *  call to psLogSetDestination(), This is equivalent to calling
+ *  psLogMsg with a level of PS_LOG_WARN.
+ *
+ */
+#ifdef DOXYGEN
+void psWarning(
+    const char* format,                ///< printf-style format of header line
+    ...                                ///< any parameters required in format
+);
+#else // #ifdef DOXYGEN
 void p_psWarning(
     const char* file,                  ///< file name
@@ -199,22 +182,15 @@
     const char* format,                ///< printf-style format of header line
     ...                                ///< any parameters required in format
+#ifdef __GNUC__
 ) __attribute__((format(printf, 4, 5)));
-#else // __GNUC__
-void p_psWarning(
-    const char* file,                  ///< file name
-    int lineno,                        ///< line number in file
-    const char* func,                  ///< function name
-    const char* format,                ///< printf-style format of header line
-    ...                                ///< any parameters required in format
-);
-#endif // __GNUC__
-
-
+#else // ifdef __GNUC__
+);
+#endif // ifdef __GNUC__
 #ifndef SWIG
-#define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
-#define psWarning(...) p_psWarning(__FILE__,__LINE__,__func__,__VA_ARGS__)
-#endif // #ifndef SWIG
-
-#endif // ! DOXYGEN
+#define psWarning(...) \
+      p_psWarning(__FILE__,__LINE__,__func__,__VA_ARGS__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Create a new psErr struct
Index: /trunk/psLib/src/sys/psErrorCodes.h.in
===================================================================
--- /trunk/psLib/src/sys/psErrorCodes.h.in	(revision 11693)
+++ /trunk/psLib/src/sys/psErrorCodes.h.in	(revision 11694)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-06 21:36:09 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,4 +32,5 @@
 } psErrorCode;
 
+
 /** An error code with description
  */
@@ -41,4 +42,5 @@
 psErrorDescription;
 
+
 /** Allocates a new psErrorDescription
  *
@@ -49,4 +51,5 @@
     const char *description            ///< the associated description
 );
+
 
 /** Retrieves the description of an error code.
@@ -60,4 +63,5 @@
     psErrorCode code                   ///< the associated error code
 );
+
 
 /** Register an error code
@@ -73,4 +77,5 @@
 );
 
+
 /** Clears error codes registered via psErrorRegister.
  *
@@ -81,4 +86,5 @@
 );
 
+
 /// @}
 #endif // #ifndef PS_ERROR_CODES_H
Index: /trunk/psLib/src/sys/psLine.h
===================================================================
--- /trunk/psLib/src/sys/psLine.h	(revision 11693)
+++ /trunk/psLib/src/sys/psLine.h	(revision 11694)
@@ -9,6 +9,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-03 06:01:42 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -30,4 +30,5 @@
 psLine;
 
+
 /** Allocates a line object of length Nline.
  *
@@ -37,4 +38,5 @@
     long Nline                         ///< length of line object to allocate
 );
+
 
 /** Checks the type of a particular pointer.
@@ -47,4 +49,5 @@
     psPtr ptr                          ///< the pointer whose type to check
 );
+
 
 /** Initializes or re-initializes a line.
@@ -59,4 +62,5 @@
 );
 
+
 /** Adds the line segment to the string.
  *
@@ -70,5 +74,10 @@
     const char *format,                ///< printf-style format of line
     ...                                ///< any parameters required in format
+#ifdef __GNUC__
+) __attribute__((format(printf, 2, 3)));
+#else // ifdef __GNUC__
 );
+#endif // ifdef __GNUC__
+
 
 /// @}
Index: /trunk/psLib/src/sys/psLogMsg.h
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.h	(revision 11693)
+++ /trunk/psLib/src/sys/psLogMsg.h	(revision 11694)
@@ -9,7 +9,8 @@
  *  @author Robert Lupton, Princeton University
  *  @author GLG, MHPCC
+ *  @author Joshua Hoblitt, University of Hawaii
  *
- *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-23 22:47:23 $
+ *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +26,23 @@
 #include "psType.h"
 
+
+///< Status codes for log messages
+enum {
+    PS_LOG_ABORT = 0,                  ///< log message is a critical error, perform an abort after printing
+    PS_LOG_ERROR,                      ///< log message is an error, but don't abort
+    PS_LOG_WARN,                       ///< log message is a warning
+    PS_LOG_INFO,                       ///< log message is informational only
+    PS_LOG_DETAIL,                     ///< log message provides details of minor interest
+    PS_LOG_MINUTIA,                    ///< log message provides very detailed information
+};
+
+
+///< Destinations for log messages
+enum {
+    PS_LOG_TO_NONE = 0,                ///< turn off logging
+    PS_LOG_TO_STDERR = 1,              ///< log to system's stderr
+    PS_LOG_TO_STDOUT = 2               ///< log to system's stdout
+};
+
 /** This procedure sets the destination for future log messages.
  *
@@ -36,10 +56,13 @@
 );
 
+
 /** This procedure returns the current log destination file descriptor.  If the
- *  destination has not been defined by the use, the descriptor for stdout is returned.
+ * destination has not been defined by the use, the descriptor for stdout is
+ * returned.
  *
  *  @return int:        The current file descriptor.
  */
 int psLogGetDestination();
+
 
 /** This procedure sets the message level for future log messages.  Subsequent
@@ -54,4 +77,5 @@
     int level                          ///< Specifies the system log level
 );
+
 
 /** This procedures returns the current log message level.
@@ -74,4 +98,5 @@
 );
 
+
 /** This procedures uses a string to set the destination for which to send
  *  the corresponding log messages.
@@ -83,4 +108,5 @@
 );
 
+
 /** This procedure logs a message to the destination set by a prior
  *  call to psLogSetDestination(), if myLevel is less than the level
@@ -89,5 +115,4 @@
  *
  */
-#ifdef __GNUC__
 void psLogMsg(
     const char *name,                  ///< name of the log source
@@ -95,19 +120,16 @@
     const char *format,                ///< printf-style format command
     ...
+#ifdef __GNUC__
 ) __attribute__((format(printf, 3, 4)));
-#else // __GNUC__
-void psLogMsg(
-    const char *name,                  ///< name of the log source
-    int level,                         ///< severity level of this log message
-    const char *format,                ///< printf-style format command
-    ...
+#else // ifdef __GNUC__
 );
-#endif // __GNUC__
+#endif // ifdef __GNUC__
 
-#ifndef SWIG
+
 /** This procedure is functionally equivalent to psLogMsg(), except that
  *  it takes a va_list as the message parameter, not a printf-style string.
  *
  */
+#ifndef SWIG
 void psLogMsgV(
     const char *name,                  ///< name of the log source
@@ -118,20 +140,4 @@
 #endif // #ifndef SWIG
 
-///< Status codes for log messages
-enum {
-    PS_LOG_ABORT = 0,                  ///< log message is a critical error, perform an abort after printing
-    PS_LOG_ERROR,                      ///< log message is an error, but don't abort
-    PS_LOG_WARN,                       ///< log message is a warning
-    PS_LOG_INFO,                       ///< log message is informational only
-    PS_LOG_DETAIL,                     ///< log message provides details of minor interest
-    PS_LOG_MINUTIA,                    ///< log message provides very detailed information
-};
-
-///< Destinations for log messages
-enum {
-    PS_LOG_TO_NONE = 0,                ///< turn off logging
-    PS_LOG_TO_STDERR = 1,              ///< log to system's stderr
-    PS_LOG_TO_STDOUT = 2               ///< log to system's stdout
-};
 
 /// @}
Index: /trunk/psLib/src/sys/psMemory.h
===================================================================
--- /trunk/psLib/src/sys/psMemory.h	(revision 11693)
+++ /trunk/psLib/src/sys/psMemory.h	(revision 11694)
@@ -15,6 +15,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-07 01:15:49 $
+ *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -131,5 +131,5 @@
     size_t size                        ///< Size required
 );
-#else // #ifdef DOXYGEN
+#else // ifdef DOXYGEN
 void *p_psAlloc(
     const char *file,                  ///< File of caller
@@ -137,506 +137,504 @@
     const char *func,                  ///< Function name of caller
     size_t size                        ///< Size required
-    #ifdef __GNUC__
+#ifdef __GNUC__
 ) __attribute__((malloc));
-# else // __GNUC__
-    );
-    #endif // __GNUC__
-
-    /// Memory allocation. psAlloc sends file and line number to p_psAlloc.
-    #ifndef SWIG
-    #define psAlloc(size) \
-    p_psAlloc(__FILE__, __LINE__, __func__, size)
-    #endif // ! SWIG
-    #endif // ! DOXYGEN
-
-
-    /** Set the deallocator routine
-     *
-     *  A deallocator routine can optionally be assigned to a memory block to
-     *  ensure that associated memory blocks also get freed, e.g., memory buffers
-     *  referenced within a struct.
-     *
-     */
-    #ifdef DOXYGEN
-    void psMemSetDeallocator(
-        void *ptr,                         ///< the memory block to operate on
-        psFreeFunc freeFunc                ///< the function to be executed at deallocation
-    );
-    #else // ifdef DOXYGEN
-    void p_psMemSetDeallocator(
-        const char *file,                   ///< File of caller
-        unsigned int lineno,                ///< Line number of caller
-        const char *func,                   ///< Function name of caller
-        void *ptr,                          ///< the memory block to operate on
-        psFreeFunc freeFunc                 ///< the function to be executed at deallocation
-    );
-    #ifndef SWIG
-    #define psMemSetDeallocator(ptr, freeFunc) \
-    p_psMemSetDeallocator(__FILE__, __LINE__, __func__, ptr, freeFunc)
-    #endif // ! SWIG
-    #endif // ifdef DOXYGEN
-
-
-    /** Get the deallocator routine
-     *
-     *  This function returns the deallocator for a memory block.  A deallocator
-     *  routine can optionally be assigned to a memory block to ensure that
-     *  associated memory blocks also get freed, e.g., memory buffers referenced
-     *  within a struct.
-     *
-     *  @return psFreeFunc    the routine to be called at deallocation.
-     */
-    #ifdef DOXYGEN
-    psFreeFunc psMemGetDeallocator(
-        void *ptr                           ///< the memory block
-    );
-    #else // ifdef DOXYGEN
-    psFreeFunc p_psMemGetDeallocator(
-        const char *file,                   ///< File of caller
-        unsigned int lineno,                ///< Line number of caller
-        const char *func,                   ///< Function name of caller
-        void *ptr                           ///< the memory block
-    );
-    #ifndef SWIG
-    #define psMemGetDeallocator(ptr) \
-    p_psMemGetDeallocator(__FILE__, __LINE__, __func__, ptr)
-    #endif // ! SWIG
-    #endif // ifdef DOXYGEN
-
-
-    /** Activate or Deactivate thread safety and mutex locking in the memory
-     * management.
-     *
-     *  psMemThreadSafety shall turn on thread safety in the memory management
-     *  functions if safe is true, and deactivate all mutex locking in the memory
-     *  management functions if safe is false.  The function shall return the
-     *  previous value of the thread safety.  Note that the default behaviour of
-     *  the library shall be for the locking to be performed.
-     *
-     *  @return bool:       The previous value of the thread safety.
-     */
-    bool psMemSetThreadSafety(
-        bool safe                          ///< boolean for turning on/off thread safety
-    );
-
-    /** Get the current state of thread safety and mutex locking in the memory
-     * management.
-     *
-     * psMemGetThreadSafety shall return the current state of thread safety in the
-     * memory management system.
-     *
-     *  @return bool:       The current state of thread safety.
-     */
-    bool psMemGetThreadSafety(void);
-
-
-    /** Set the memory as persistent so that it is ignored when detecting memory
-     * leaks.
-     *
-     *  Used to mark a memory block as persistent data within the library,
-     *  i.e., non user-level data used to hold psLib's state or cache data.  Such
-     *  examples of this class of memory is psTrace's trace-levels and dynamic
-     *  error codes.
-     *
-     *  Memory marked as persistent is excluded from memory leak checks.
-     *
-     */
-    #ifdef DOXYGEN
-    void psMemSetPersistent(
-        void *ptr,                          ///< the memory block to operate on
-        bool value,                         ///< true if memory is persistent, otherwise false
-    );
-    #else // #ifdef DOXYGEN
-    void p_psMemSetPersistent(
-        const char *file,                   ///< File of caller
-        unsigned int lineno,                ///< Line number of caller
-        const char *func,                   ///< Function name of caller
-        void *ptr,                          ///< the memory block to operate on
-        bool value                          ///< true if memory is persistent, otherwise false
-    );
-    #ifndef SWIG
-    #define psMemSetPersistent(ptr, value) \
-    p_psMemSetPersistent(__FILE__, __LINE__, __func__, ptr, value)
-    #endif // ! SWIG
-    #endif // DOXYGEN
-
-
-    /** Set whether allocated memory is persistent
-     *
-     *  Set whether allocated memory is persistent. The defeault is false.
-     *
-     *  @return bool:       The previous value of whether all allocated memory is
-     *  persistent
-     */
-    bool p_psMemAllocatePersistent(bool is_persistent); ///< Should all memory allocated be persistent?
-
-
-    /** Get the memory's persistent flag.
-     *
-     *  Checks if a memory block has been marked as persistent by
-     *  p_psMemSetPresistent.
-     *
-     *  Memory marked as persistent is excluded from memory leak checks.
-     *
-     *  @return bool    true if memory is marked persistent, otherwise false.
-     */
-    #ifdef DOXYGEN
-    bool psMemGetPersistent(
-        void *ptr,                          ///< the memory block to check.
-    );
-    #else // ifdef DOXYGEN
-    bool p_psMemGetPersistent(
-        const char *file,                   ///< File of caller
-        unsigned int lineno,                ///< Line number of caller
-        const char *func,                   ///< Function name of caller
-        void *ptr                           ///< the memory block to check.
-    );
-    #ifndef SWIG
-    #define psMemGetPersistent(ptr) \
-    p_psMemGetPersistent(__FILE__, __LINE__, __func__, ptr)
-    #endif // ! SWIG
-    #endif // DOXYGEN
-
-
-    /** Memory re-allocation.  This operates much like realloc(), but is guaranteed
-     * to return a non-NULL value.
-     *
-     *  @return void * pointer to resized buffer. This will not be NULL.
-     *  @see psAlloc, psFree
-     */
-    #ifdef DOXYGEN
-    void *psRealloc(
-        void *ptr,                          ///< Pointer to re-allocate
-        size_t size                         ///< Size required
-    );
-    #else // #ifdef DOXYGEN
-    void *p_psRealloc(
-        const char *file,                   ///< File of caller
-        unsigned int lineno,                ///< Line number of caller
-        const char *func,                   ///< Function name of caller
-        void *ptr,                          ///< Pointer to re-allocate
-        size_t size                         ///< Size required
-        #ifdef __GNUC__
-    ) __attribute__((malloc));
-    # else // __GNUC__
-        );
-        #endif // __GNUC__
-        #ifndef SWIG
-        #define psRealloc(ptr, size) \
-        p_psRealloc(__FILE__, __LINE__, __func__, ptr, size)
-        #endif // ! SWIG
-        #endif // ! DOXYGEN
-
-
-        /** Free memory.  This operates much like free().
-         *
-         *  @see psAlloc, psRealloc
-         */
-        #ifdef DOXYGEN
-        void psFree(
-            void *ptr                           ///< Pointer to free, if NULL, function returns immediately.
-        );
-        #else // #ifdef DOXYGEN
-        /// Free memory.  psFree sends file and line number to p_psFree.
-        #ifndef SWIG
-        #define psFree(ptr) \
+# else // ifdef __GNUC__
+);
+#endif // ifdef __GNUC__
+#ifndef SWIG
+#define psAlloc(size) \
+p_psAlloc(__FILE__, __LINE__, __func__, size)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Set the deallocator routine
+ *
+ *  A deallocator routine can optionally be assigned to a memory block to
+ *  ensure that associated memory blocks also get freed, e.g., memory buffers
+ *  referenced within a struct.
+ *
+ */
+#ifdef DOXYGEN
+void psMemSetDeallocator(
+    void *ptr,                         ///< the memory block to operate on
+    psFreeFunc freeFunc                ///< the function to be executed at deallocation
+);
+#else // ifdef DOXYGEN
+void p_psMemSetDeallocator(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    void *ptr,                          ///< the memory block to operate on
+    psFreeFunc freeFunc                 ///< the function to be executed at deallocation
+);
+#ifndef SWIG
+#define psMemSetDeallocator(ptr, freeFunc) \
+      p_psMemSetDeallocator(__FILE__, __LINE__, __func__, ptr, freeFunc)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Get the deallocator routine
+ *
+ *  This function returns the deallocator for a memory block.  A deallocator
+ *  routine can optionally be assigned to a memory block to ensure that
+ *  associated memory blocks also get freed, e.g., memory buffers referenced
+ *  within a struct.
+ *
+ *  @return psFreeFunc    the routine to be called at deallocation.
+ */
+#ifdef DOXYGEN
+psFreeFunc psMemGetDeallocator(
+    void *ptr                           ///< the memory block
+);
+#else // ifdef DOXYGEN
+psFreeFunc p_psMemGetDeallocator(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    void *ptr                           ///< the memory block
+);
+#ifndef SWIG
+#define psMemGetDeallocator(ptr) \
+      p_psMemGetDeallocator(__FILE__, __LINE__, __func__, ptr)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Activate or Deactivate thread safety and mutex locking in the memory
+ * management.
+ *
+ *  psMemThreadSafety shall turn on thread safety in the memory management
+ *  functions if safe is true, and deactivate all mutex locking in the memory
+ *  management functions if safe is false.  The function shall return the
+ *  previous value of the thread safety.  Note that the default behaviour of
+ *  the library shall be for the locking to be performed.
+ *
+ *  @return bool:       The previous value of the thread safety.
+ */
+bool psMemSetThreadSafety(
+    bool safe                          ///< boolean for turning on/off thread safety
+);
+
+
+/** Get the current state of thread safety and mutex locking in the memory
+ * management.
+ *
+ * psMemGetThreadSafety shall return the current state of thread safety in the
+ * memory management system.
+ *
+ *  @return bool:       The current state of thread safety.
+ */
+bool psMemGetThreadSafety(void);
+
+
+/** Set the memory as persistent so that it is ignored when detecting memory
+ * leaks.
+ *
+ *  Used to mark a memory block as persistent data within the library,
+ *  i.e., non user-level data used to hold psLib's state or cache data.  Such
+ *  examples of this class of memory is psTrace's trace-levels and dynamic
+ *  error codes.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ */
+#ifdef DOXYGEN
+void psMemSetPersistent(
+    void *ptr,                          ///< the memory block to operate on
+    bool value,                         ///< true if memory is persistent, otherwise false
+);
+#else // ifdef DOXYGEN
+void p_psMemSetPersistent(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    void *ptr,                          ///< the memory block to operate on
+    bool value                          ///< true if memory is persistent, otherwise false
+);
+#ifndef SWIG
+#define psMemSetPersistent(ptr, value) \
+      p_psMemSetPersistent(__FILE__, __LINE__, __func__, ptr, value)
+#endif // idndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Set whether allocated memory is persistent
+ *
+ *  Set whether allocated memory is persistent. The defeault is false.
+ *
+ *  @return bool:       The previous value of whether all allocated memory is
+ *  persistent
+ */
+bool p_psMemAllocatePersistent(bool is_persistent); ///< Should all memory allocated be persistent?
+
+
+/** Get the memory's persistent flag.
+ *
+ *  Checks if a memory block has been marked as persistent by
+ *  p_psMemSetPresistent.
+ *
+ *  Memory marked as persistent is excluded from memory leak checks.
+ *
+ *  @return bool    true if memory is marked persistent, otherwise false.
+ */
+#ifdef DOXYGEN
+bool psMemGetPersistent(
+    void *ptr,                          ///< the memory block to check.
+);
+#else // ifdef DOXYGEN
+bool p_psMemGetPersistent(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    void *ptr                           ///< the memory block to check.
+);
+#ifndef SWIG
+#define psMemGetPersistent(ptr) \
+      p_psMemGetPersistent(__FILE__, __LINE__, __func__, ptr)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Memory re-allocation.  This operates much like realloc(), but is guaranteed
+ * to return a non-NULL value.
+ *
+ *  @return void * pointer to resized buffer. This will not be NULL.
+ *  @see psAlloc, psFree
+ */
+#ifdef DOXYGEN
+void *psRealloc(
+    void *ptr,                          ///< Pointer to re-allocate
+    size_t size                         ///< Size required
+);
+#else // ifdef DOXYGEN
+void *p_psRealloc(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    void *ptr,                          ///< Pointer to re-allocate
+    size_t size                         ///< Size required
+#ifdef __GNUC__
+) __attribute__((malloc));
+# else // ifdef __GNUC__
+);
+#endif // ifdef __GNUC__
+#ifndef SWIG
+#define psRealloc(ptr, size) \
+      p_psRealloc(__FILE__, __LINE__, __func__, ptr, size)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Free memory.  This operates much like free().
+ *
+ *  @see psAlloc, psRealloc
+ */
+#ifdef DOXYGEN
+void psFree(
+    void *ptr                           ///< Pointer to free, if NULL, function returns immediately.
+);
+#else // ifdef DOXYGEN
+#ifndef SWIG
+#define psFree(ptr) \
         psMemDecrRefCounter(ptr)
-        #endif // ! SWIG
-        #endif // ! DOXYGEN
-
-
-        /** Check for memory leaks.  This scans for allocated memory buffers not freed
-         * with an ID not less than id0.  This is used to check for memory leaks by: -#
-         * before a block of code to be checked, store the current ID count via
-         * psGetMemId -# after the block of code to be checked, call this function
-         * using the ID stored above.  If all memory in the block that was allocated
-         * has been freed, this call should output nothing and return 0.
-         *
-         *  If memory leaks are found, the Memory Problem callback will be called as
-         *  well.
-         *
-         *  @return int  number of memory blocks found as 'leaks', i.e., the number of
-         *  currently allocated memory blocks above id0 that have not been freed.  @see
-         *  psAlloc, psFree, psgetMemId, psMemProblemCallbackSet
-         */
-        #ifdef DOXYGEN
-        int psMemCheckLeaks(
-            psMemId id0,                       ///< don't list blocks with id < id0
-            psMemBlock ***array,               ///< pointer to array of pointers to leaked blocks, or NULL
-            FILE * fd,                         ///< print list of leaks to fd (or NULL)
-            bool persistence                   ///< make check across all object even persistent ones
-        );
-        #else // ifdef DOXYGEN
-        int p_psMemCheckLeaks(
-            const char *file,                   ///< File of caller
-            unsigned int lineno,                ///< Line number of caller
-            const char *func,                   ///< Function name of caller
-            psMemId id0,                        ///< don't list blocks with id < id0
-            psMemBlock ***array,                ///< pointer to array of pointers to leaked blocks, or NULL
-            FILE * fd,                          ///< print list of leaks to fd (or NULL)
-            bool persistence                    ///< make check across all object even persistent ones
-        );
-        #ifndef SWIG
-        #define psMemCheckLeaks(id0, array, fd, persistence) \
-        p_psMemCheckLeaks(__FILE__, __LINE__, __func__, id0, array, fd, persistence)
-        #endif // ifndef SWIG
-        #endif // ifdef DOXYGEN
-
-
-        /** Check for memory corruption.  Scans all currently allocated memory buffers
-         * and checks for corruptions, i.e., invalid markers that signify a buffer
-         * under/overflow.
-         *
-         *  @return int
-         *
-         */
-        #ifdef DOXYGEN
-        int psMemCheckCorruption(
-            FILE *output,                       ///< FILE to write corrupted blocks too
-            bool abort_on_error                 ///< Abort on detecting corruption?
-        );
-        #else // ifdef DOXYGEN
-        int p_psMemCheckCorruption(
-            const char *file,                   ///< File of caller
-            unsigned int lineno,                ///< Line number of caller
-            const char *func,                   ///< Function name of caller
-            FILE *output,                       ///< FILE to write corrupted blocks too
-            bool abort_on_error                 ///< Abort on detecting corruption?
-        );
-        #ifndef SWIG
-        #define psMemCheckCorruption(output, abort_on_error) \
-        p_psMemCheckCorruption(__FILE__, __LINE__, __func__, output, abort_on_error)
-        #endif // ifndef SWIG
-        #endif // ifdef DOXYGEN
-
-
-        /** Return reference counter
-         *
-         *  @return psReferenceCount
-         *
-         */
-        #ifdef DOXYGEN
-        psReferenceCount psMemGetRefCounter(
-            void *ptr                     ///< Pointer to get refCounter for
-        );
-
-        #else // ifdef DOXYGEN
-        psReferenceCount p_psMemGetRefCounter(
-            const char *file,                   ///< File of call
-            unsigned int lineno,                ///< Line number of call
-            const char *func,                   ///< Function name of caller
-            void *ptr                           ///< Pointer to get refCounter for
-        );
-        #ifndef SWIG
-        #define psMemGetRefCounter(ptr) \
-        p_psMemGetRefCounter(__FILE__, __LINE__, __func__, ptr)
-        #endif // !SWIG
-        #endif // !DOXYGEN
-
-
-        /** Increment reference counter and return the pointer
-         *
-         *  @return void *
-         *
-         */
-        #ifdef DOXYGEN
-        void *psMemIncrRefCounter(
-            void *ptr                           ///< Pointer to increment refCounter, and return
-        );
-        #else // ifdef DOXYGEN
-        void *p_psMemIncrRefCounter(
-            const char *file,                   ///< File of call
-            unsigned int lineno,                ///< Line number of call
-            const char *func,                   ///< Function name of caller
-            void *ptr                           ///< Pointer to increment refCounter, and return
-        );
-        #ifndef SWIG
-        #define psMemIncrRefCounter(ptr) \
-        p_psMemIncrRefCounter(__FILE__, __LINE__, __func__, ptr)
-        #endif // !SWIG
-        #endif // !DOXYGEN
-
-
-        /** Decrement reference counter and return the pointer
-         *
-         *
-         *  @return void *    the pointer deremented in refCount, or NULL if pointer is
-         *                   fully dereferenced.
-         */
-        #ifdef DOXYGEN
-        void *psMemDecrRefCounter(
-            void *ptr                           ///< Pointer to decrement refCounter, and return
-        );
-        #else // DOXYGEN
-        void *p_psMemDecrRefCounter(
-            const char *file,                   ///< File of call
-            unsigned int lineno,                ///< Line number of call
-            const char *func,                   ///< Function name of caller
-            void *ptr                           ///< Pointer to decrement refCounter, and return
-        );
-        #ifndef SWIG
-        #define psMemDecrRefCounter(ptr) \
-        p_psMemDecrRefCounter(__FILE__, __LINE__, __func__, ptr)
-        #endif // !SWIG
-        #endif // !DOXYGEN
-
-
-        #if 0 // psMemSetRefCounter
-        /** Set reference counter and return the pointer
-         *
-         *  @return void *    the pointer with refCount set, or NULL if pointer is
-         *                   fully dereferenced.
-         */
-        #ifdef DOXYGEN
-        void * psMemSetRefCounter(
-            void * ptr,                        ///< Pointer to decrement refCounter, and return
-            psReferenceCount count            ///< New reference count
-        );
-        #else // DOXYGEN
-        void * p_psMemSetRefCounter(
-            void * vptr,                        ///< Pointer to decrement refCounter, and return
-            psReferenceCount count,            ///< New reference count
-            const char *file,                  ///< File of call
-            psS32 lineno                       ///< Line number of call
-        );
-
-        #ifndef SWIG
-        #define psMemSetRefCounter(vptr, count) p_psMemSetRefCounter(vptr, count, __FILE__, __LINE__)
-        #endif // !SWIG
-
-        #endif // !DOXYGEN
-        #endif // psMemSetRefCounter
-
-        /** Set callback for out-of-memory.
-         *
-         *  If not enough memory is available to satisfy a request by psAlloc or
-         *  psRealloc, these functions attempt to find an alternative solution by
-         *  calling the psMemExhaustedCallback, a function which may be set by the
-         *  programmer in appropriate circumstances, rather than immediately fail.
-         *  The typical use of such a feature may be when a program needs a large
-         *  chunk of memory to do an operation, but the exact size is not critical.
-         *  This feature gives the programmer the opportunity to make a smaller
-         *  request and try again, limiting the size of the operating buffer.
-         *
-         *  @return psMemExhaustedCallback     old psMemExhaustedCallback function
-         */
-        psMemExhaustedCallback psMemExhaustedCallbackSet(
-            psMemExhaustedCallback func        ///< Function to run at memory exhaustion
-        );
-
-
-        /** Set call back for when a particular memory block is allocated
-         *
-         *  A private variable, p_psMemAllocID, can be used to trace the allocation
-         *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
-         *  memory block with that ID is allocated, psMemAllocCallback is called
-         *  just before memory is returned to the calling function.
-         *
-         *  @return psMemAllocCallback      old psMemAllocCallback function
-         */
-        psMemAllocCallback psMemAllocCallbackSet(
-            psMemAllocCallback func            ///< Function to run at memory allocation of specific mem block
-        );
-
-
-        /** Set call back for when a particular memory block is freed
-         *
-         *  A private variable, p_psMemFreeID, can be used to trace the freeing of
-         *  specific memory blocks. If p_psMemFreeID is set and the memory block with
-         *  the ID is about to be freed, the psMemFreeCallback callback is called just
-         *  before the memory block is freed.
-         *
-         *  @return psMemFreeCallback          old psMemFreeCallback function
-         */
-        psMemFreeCallback psMemFreeCallbackSet(
-            psMemFreeCallback func             ///< Function to run at memory free of specific mem block
-        );
-
-
-        /** get next memory ID
-         *
-         *  @return psMemId                 the next memory ID to be used
-         */
-        psMemId psMemGetId(void);
-
-
-        /** get the last memory ID used
-         *
-         *  @return psMemId                 the last memory ID used
-         */
-        psMemId psMemGetLastId(void);
-
-
-        /** set p_psMemAllocID to specific id
-         *
-         *  A private variable, p_psMemAllocID, can be used to trace the allocation
-         *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
-         *  memory block with that ID is allocated, psMemAllocCallback is called
-         *  just before memory is returned to the calling function.
-         *
-         *  @return psMemId
-         *
-         *  @see psMemAllocCallbackSet
-         */
-        psMemId psMemAllocCallbackSetID(
-            psMemId id                         ///< ID to set
-        );
-
-
-        /** set p_psMemFreeID to id
-         *
-         *  A private variable, p_psMemFreeID, can be used to trace the freeing of
-         *  specific memory blocks. If p_psMemFreeID is set and the memory block with
-         *  the ID is about to be freed, the psMemFreeCallback callback is called just
-         *  before the memory block is freed.
-         *
-         *  @return psMemId                 the old p_psMemFreeID
-         *
-         *  @see psMemFreeCallbackSet
-         */
-        psMemId psMemFreeCallbackSetID(
-            psMemId id                         ///< ID to set
-        );
-
-
-        /** return statistics on memory usage
-         *
-         * @return the total amount of memory owned by psLib; if non-NULL also provide
-         * a breakdown into allocated and allocated-and-persistent
-         */
-        size_t psMemStats(const bool print, ///< print details as they're found?
-                          size_t *allocated, ///< memory that's currently allocated (but not persistent)
-                          size_t *persistent); ///< persistent memory that's currently allocated
-
-        /** print detailed information about a psMemBlock
-         *
-         * This function prints a detailed description of a psMemBlock to output.
-         *
-         * @return the return status of fprintf()
-         */
-        int psMemBlockPrint(
-            FILE *output,                       ///< FILE to write information too
-            const psMemBlock *memBlock          ///< psMemBlock to be examined
-        );
-
-
-        /// @} end of SysUtils
-
-        #ifndef DOXYGEN
-
-        /*
-         * Ensure that any program using malloc/realloc/free will fail to compile
-         */
-        #ifndef PS_ALLOW_MALLOC
-        #ifdef __GNUC__
-        #pragma GCC poison malloc realloc calloc free
-        #else // __GNUC__
-        #define malloc(S)       _Pragma("error Use of malloc is not allowed.  Use psAlloc instead.")
-        #define realloc(P,S)    _Pragma("error Use of realloc is not allowed.  Use psRealloc instead.")
-        #define calloc(S)       _Pragma("error Use of calloc is not allowed.  Use psAlloc instead.")
-        #define free(P)         _Pragma("error Use of free is not allowed.  Use psFree instead.")
-        #endif // ! __GNUC__
-        #endif // #ifndef PS_ALLOW_MALLOC
-
-        #endif // #ifndef DOXYGEN
-        #endif // #ifndef PS_MEMORY_H
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Check for memory leaks.  This scans for allocated memory buffers not freed
+ * with an ID not less than id0.  This is used to check for memory leaks by: -#
+ * before a block of code to be checked, store the current ID count via
+ * psGetMemId -# after the block of code to be checked, call this function
+ * using the ID stored above.  If all memory in the block that was allocated
+ * has been freed, this call should output nothing and return 0.
+ *
+ *  If memory leaks are found, the Memory Problem callback will be called as
+ *  well.
+ *
+ *  @return int  number of memory blocks found as 'leaks', i.e., the number of
+ *  currently allocated memory blocks above id0 that have not been freed.  @see
+ *  psAlloc, psFree, psgetMemId, psMemProblemCallbackSet
+ */
+#ifdef DOXYGEN
+int psMemCheckLeaks(
+    psMemId id0,                       ///< don't list blocks with id < id0
+    psMemBlock ***array,               ///< pointer to array of pointers to leaked blocks, or NULL
+    FILE * fd,                         ///< print list of leaks to fd (or NULL)
+    bool persistence                   ///< make check across all object even persistent ones
+);
+#else // ifdef DOXYGEN
+int p_psMemCheckLeaks(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    psMemId id0,                        ///< don't list blocks with id < id0
+    psMemBlock ***array,                ///< pointer to array of pointers to leaked blocks, or NULL
+    FILE * fd,                          ///< print list of leaks to fd (or NULL)
+    bool persistence                    ///< make check across all object even persistent ones
+);
+#ifndef SWIG
+#define psMemCheckLeaks(id0, array, fd, persistence) \
+      p_psMemCheckLeaks(__FILE__, __LINE__, __func__, id0, array, fd, persistence)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Check for memory corruption.  Scans all currently allocated memory buffers
+ * and checks for corruptions, i.e., invalid markers that signify a buffer
+ * under/overflow.
+ *
+ *  @return int
+ *
+ */
+#ifdef DOXYGEN
+int psMemCheckCorruption(
+    FILE *output,                       ///< FILE to write corrupted blocks too
+    bool abort_on_error                 ///< Abort on detecting corruption?
+);
+#else // ifdef DOXYGEN
+int p_psMemCheckCorruption(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    FILE *output,                       ///< FILE to write corrupted blocks too
+    bool abort_on_error                 ///< Abort on detecting corruption?
+);
+#ifndef SWIG
+#define psMemCheckCorruption(output, abort_on_error) \
+      p_psMemCheckCorruption(__FILE__, __LINE__, __func__, output, abort_on_error)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Return reference counter
+ *
+ *  @return psReferenceCount
+ *
+ */
+#ifdef DOXYGEN
+psReferenceCount psMemGetRefCounter(
+    void *ptr                     ///< Pointer to get refCounter for
+);
+
+#else // ifdef DOXYGEN
+psReferenceCount p_psMemGetRefCounter(
+    const char *file,                   ///< File of call
+    unsigned int lineno,                ///< Line number of call
+    const char *func,                   ///< Function name of caller
+    void *ptr                           ///< Pointer to get refCounter for
+);
+#ifndef SWIG
+#define psMemGetRefCounter(ptr) \
+      p_psMemGetRefCounter(__FILE__, __LINE__, __func__, ptr)
+#endif // !SWIG
+#endif // !DOXYGEN
+
+
+/** Increment reference counter and return the pointer
+ *
+ *  @return void *
+ *
+ */
+#ifdef DOXYGEN
+void *psMemIncrRefCounter(
+    void *ptr                           ///< Pointer to increment refCounter, and return
+);
+#else // ifdef DOXYGEN
+void *p_psMemIncrRefCounter(
+    const char *file,                   ///< File of call
+    unsigned int lineno,                ///< Line number of call
+    const char *func,                   ///< Function name of caller
+    void *ptr                           ///< Pointer to increment refCounter, and return
+);
+#ifndef SWIG
+#define psMemIncrRefCounter(ptr) \
+      p_psMemIncrRefCounter(__FILE__, __LINE__, __func__, ptr)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Decrement reference counter and return the pointer
+ *
+ *
+ *  @return void *    the pointer deremented in refCount, or NULL if pointer is
+ *                   fully dereferenced.
+ */
+#ifdef DOXYGEN
+void *psMemDecrRefCounter(
+    void *ptr                           ///< Pointer to decrement refCounter, and return
+);
+#else // DOXYGEN
+void *p_psMemDecrRefCounter(
+    const char *file,                   ///< File of call
+    unsigned int lineno,                ///< Line number of call
+    const char *func,                   ///< Function name of caller
+    void *ptr                           ///< Pointer to decrement refCounter, and return
+);
+#ifndef SWIG
+#define psMemDecrRefCounter(ptr) \
+      p_psMemDecrRefCounter(__FILE__, __LINE__, __func__, ptr)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+#if 0 // psMemSetRefCounter
+/** Set reference counter and return the pointer
+ *
+ *  @return void *    the pointer with refCount set, or NULL if pointer is
+ *                   fully dereferenced.
+ */
+#ifdef DOXYGEN
+void * psMemSetRefCounter(
+    void * ptr,                        ///< Pointer to decrement refCounter, and return
+    psReferenceCount count            ///< New reference count
+);
+#else // DOXYGEN
+void * p_psMemSetRefCounter(
+    void * vptr,                        ///< Pointer to decrement refCounter, and return
+    psReferenceCount count,            ///< New reference count
+    const char *file,                  ///< File of call
+    psS32 lineno                       ///< Line number of call
+);
+
+#ifndef SWIG
+#define psMemSetRefCounter(vptr, count) p_psMemSetRefCounter(vptr, count, __FILE__, __LINE__)
+#endif // !SWIG
+
+#endif // !DOXYGEN
+#endif // psMemSetRefCounter
+
+/** Set callback for out-of-memory.
+ *
+ *  If not enough memory is available to satisfy a request by psAlloc or
+ *  psRealloc, these functions attempt to find an alternative solution by
+ *  calling the psMemExhaustedCallback, a function which may be set by the
+ *  programmer in appropriate circumstances, rather than immediately fail.
+ *  The typical use of such a feature may be when a program needs a large
+ *  chunk of memory to do an operation, but the exact size is not critical.
+ *  This feature gives the programmer the opportunity to make a smaller
+ *  request and try again, limiting the size of the operating buffer.
+ *
+ *  @return psMemExhaustedCallback     old psMemExhaustedCallback function
+ */
+psMemExhaustedCallback psMemExhaustedCallbackSet(
+    psMemExhaustedCallback func        ///< Function to run at memory exhaustion
+);
+
+
+/** Set call back for when a particular memory block is allocated
+ *
+ *  A private variable, p_psMemAllocID, can be used to trace the allocation
+ *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
+ *  memory block with that ID is allocated, psMemAllocCallback is called
+ *  just before memory is returned to the calling function.
+ *
+ *  @return psMemAllocCallback      old psMemAllocCallback function
+ */
+psMemAllocCallback psMemAllocCallbackSet(
+    psMemAllocCallback func            ///< Function to run at memory allocation of specific mem block
+);
+
+
+/** Set call back for when a particular memory block is freed
+ *
+ *  A private variable, p_psMemFreeID, can be used to trace the freeing of
+ *  specific memory blocks. If p_psMemFreeID is set and the memory block with
+ *  the ID is about to be freed, the psMemFreeCallback callback is called just
+ *  before the memory block is freed.
+ *
+ *  @return psMemFreeCallback          old psMemFreeCallback function
+ */
+psMemFreeCallback psMemFreeCallbackSet(
+    psMemFreeCallback func             ///< Function to run at memory free of specific mem block
+);
+
+
+/** get next memory ID
+ *
+ *  @return psMemId                 the next memory ID to be used
+ */
+psMemId psMemGetId(void);
+
+
+/** get the last memory ID used
+ *
+ *  @return psMemId                 the last memory ID used
+ */
+psMemId psMemGetLastId(void);
+
+
+/** set p_psMemAllocID to specific id
+ *
+ *  A private variable, p_psMemAllocID, can be used to trace the allocation
+ *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
+ *  memory block with that ID is allocated, psMemAllocCallback is called
+ *  just before memory is returned to the calling function.
+ *
+ *  @return psMemId
+ *
+ *  @see psMemAllocCallbackSet
+ */
+psMemId psMemAllocCallbackSetID(
+    psMemId id                         ///< ID to set
+);
+
+
+/** set p_psMemFreeID to id
+ *
+ *  A private variable, p_psMemFreeID, can be used to trace the freeing of
+ *  specific memory blocks. If p_psMemFreeID is set and the memory block with
+ *  the ID is about to be freed, the psMemFreeCallback callback is called just
+ *  before the memory block is freed.
+ *
+ *  @return psMemId                 the old p_psMemFreeID
+ *
+ *  @see psMemFreeCallbackSet
+ */
+psMemId psMemFreeCallbackSetID(
+    psMemId id                         ///< ID to set
+);
+
+
+/** return statistics on memory usage
+ *
+ * @return the total amount of memory owned by psLib; if non-NULL also provide
+ * a breakdown into allocated and allocated-and-persistent
+ */
+size_t psMemStats(const bool print, ///< print details as they're found?
+                  size_t *allocated, ///< memory that's currently allocated (but not persistent)
+                  size_t *persistent); ///< persistent memory that's currently allocated
+
+/** print detailed information about a psMemBlock
+ *
+ * This function prints a detailed description of a psMemBlock to output.
+ *
+ * @return the return status of fprintf()
+ */
+int psMemBlockPrint(
+    FILE *output,                       ///< FILE to write information too
+    const psMemBlock *memBlock          ///< psMemBlock to be examined
+);
+
+
+/// @} end of SysUtils
+
+#ifndef DOXYGEN
+
+/*
+ * Ensure that any program using malloc/realloc/free will fail to compile
+ */
+#ifndef PS_ALLOW_MALLOC
+#ifdef __GNUC__
+#pragma GCC poison malloc realloc calloc free
+#else // ifdef __GNUC__
+#define malloc(S)       _Pragma("error Use of malloc is not allowed.  Use psAlloc instead.")
+#define realloc(P,S)    _Pragma("error Use of realloc is not allowed.  Use psRealloc instead.")
+#define calloc(S)       _Pragma("error Use of calloc is not allowed.  Use psAlloc instead.")
+#define free(P)         _Pragma("error Use of free is not allowed.  Use psFree instead.")
+#endif // ifdef __GNUC__
+#endif // ifndef PS_ALLOW_MALLOC
+
+#endif // #ifndef DOXYGEN
+#endif // #ifndef PS_MEMORY_H
Index: /trunk/psLib/src/sys/psString.h
===================================================================
--- /trunk/psLib/src/sys/psString.h	(revision 11693)
+++ /trunk/psLib/src/sys/psString.h	(revision 11694)
@@ -9,7 +9,8 @@
  * @author Eric Van Alst, MHPCC
  * @author David Robbins, MHPCC
- *
- * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-02-03 05:35:30 $
+ * @author Joshua Hoblitt, University of Hawaii
+ *
+ * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-02-08 01:59:28 $
  *
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -31,5 +32,9 @@
 
 /** This macro returns a (static buffer containing) "file:line" */
+#ifdef __GNUC__
+const char *p_psFileLine(const char *file, int line) __attribute__((deprecated));
+#else // ifdef __GNUC__
 const char *p_psFileLine(const char *file, int line);
+#endif // ifdef __GNUC__
 #define PS_FILE_LINE p_psFileLine(__FILE__,__LINE__)
 
@@ -42,7 +47,9 @@
 );
 
+
 /** Checks the type of a particular pointer.
  *
- *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
+ *  Uses the appropriate deallocation function in psMemBlock to check the ptr
+ *  datatype.
  *
  *  @return bool:       True if the pointer matches a psString structure, false otherwise.
@@ -51,4 +58,5 @@
     psPtr ptr                          ///< the pointer whose type to check
 );
+
 
 /** Copies the input string
@@ -63,4 +71,5 @@
     const char *string                 ///< Input string of characters to copy
 );
+
 
 /** Copies the input string up to the specified number of characters
@@ -81,4 +90,5 @@
 );
 
+
 /** Appends a format onto a string
  *
@@ -88,53 +98,47 @@
  * @return ssize_t:     The length of the new string (excluding '\0')
  */
+ssize_t psStringAppend(
+    char **dest,                        ///< existing string
+    const char *format,                 ///< format to append
+    ...                                 ///< format arguments
 #ifdef __GNUC__
-ssize_t psStringAppend(
-    char **dest,                        ///< existing string
-    const char *format,                 ///< format to append
-    ...                                 ///< format arguments
 ) __attribute__((format(printf, 2, 3)));
 #else // __GNUC__
-ssize_t psStringAppend(
+);
+#endif // __GNUC__
+
+
+/** Appends a format onto a string
+ *
+ * This function shall allocate a new string if dest is NULL.  dest shall be
+ * automatically extended to the size of the new string.
+ *
+ * @return ssize_t:     The length of the new string (excluding '\0')
+ */
+ssize_t psStringAppendV(
+    char **dest,                        ///< existing string
+    const char *format,                 ///< format to append
+    va_list ap                          ///< va_list of format arguments
+);
+
+
+/** Prepends a format onto a string
+ *
+ * This function shall allocate a new string if dest is NULL.  dest shall be
+ * automatically extended to the size of the new string.
+ *
+ * @return ssize_t:     The length of the new string (excluding '\0')
+ */
+ssize_t psStringPrepend(
     char **dest,                        ///< existing string
     const char *format,                 ///< format to append
     ...                                 ///< format arguments
-);
-#endif // __GNUC__
-
-/** Appends a format onto a string
- *
- * This function shall allocate a new string if dest is NULL.  dest shall be
- * automatically extended to the size of the new string.
- *
- * @return ssize_t:     The length of the new string (excluding '\0')
- */
-ssize_t psStringAppendV(
-    char **dest,                        ///< existing string
-    const char *format,                 ///< format to append
-    va_list ap                          ///< va_list of format arguments
-);
-
-/** Prepends a format onto a string
- *
- * This function shall allocate a new string if dest is NULL.  dest shall be
- * automatically extended to the size of the new string.
- *
- * @return ssize_t:     The length of the new string (excluding '\0')
- */
 #ifdef __GNUC__
-ssize_t psStringPrepend(
-    char **dest,                        ///< existing string
-    const char *format,                 ///< format to append
-    ...                                 ///< format arguments
 ) __attribute__((format(printf, 2, 3)));
 # else // __GNUC__
-
-    ssize_t psStringPrepend(
-        char **dest,                        ///< existing string
-        const char *format,                 ///< format to append
-        ...                                 ///< format arguments
-    );
+);
 #endif // __GNUC__
 
+
 /** Prepends a format onto a string
  *
@@ -149,4 +153,5 @@
     va_list ap                          ///< va_list of format arguments
 );
+
 
 /** Procedure to split the input string into a psList of psStrings.
@@ -163,4 +168,5 @@
 );
 
+
 /** Procedure to split the input string into a psArray of psStrings.
  *
@@ -176,10 +182,11 @@
 );
 
-// Given the input string, search for all copies of the key, and replace with the replacement value
-// the input string may be freed if not needed
+// Given the input string, search for all copies of the key, and replace with
+// the replacement value the input string may be freed if not needed
 /** Procedure to search an input string and substitute strings where desired.
  *
- *  The input string is searched for all instances of the key, which is then replaced with
- *  the replacement value wherever found.  The input string may be freed if not needed.
+ *  The input string is searched for all instances of the key, which is then
+ *  replaced with the replacement value wherever found.  The input string may
+ *  be freed if not needed.
  *
  *  @return ssize_t:      the length of the new string (excluding '\0')
@@ -191,4 +198,5 @@
 );
 
+
 // strip whitespace from head and tail of string
 /** Procedure to strip the whitespace from the head and tail of a string.
@@ -199,4 +207,5 @@
     char *string                       ///< input string to be stripped.
 );
+
 
 /// Given a CVS keyword string, strip off the CVS-specific keyword to get the value
@@ -222,4 +231,5 @@
 #endif // ifndef DOXYGEN
 
+
 /// @}
 #endif // #ifndef PS_STRING_H
Index: /trunk/psLib/src/sys/psTrace.h
===================================================================
--- /trunk/psLib/src/sys/psTrace.h	(revision 11693)
+++ /trunk/psLib/src/sys/psTrace.h	(revision 11694)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-31 00:38:46 $
+ *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-08 01:59:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -69,4 +69,5 @@
 p_psComponent;
 
+
 /** This procedure sets the trace format for future trace messages.  The argument
  *  must be a character string consistsing of the letters H (host), L
@@ -82,6 +83,6 @@
 );
 
+/** Sends a trace message. */
 #ifdef DOXYGEN
-/** Sends a trace message. */
 void psTrace(
     const char *facil,                 ///< facilty of interest
@@ -90,16 +91,5 @@
     ...                                ///< trace message arguments
 );
-
-/** Get the trace level
- *
- *  @return int:    Trace Level
- */
-int psTraceGetLevel(
-    const char *facil                  ///< facilty of interest
-);
-
-#else // DOXYGEN
-#ifdef __GNUC__
-/// Send a trace message
+#else // ifdef DOXYGEN
 void p_psTrace(
     const char* file,                  ///< file name
@@ -110,16 +100,15 @@
     const char *format,                ///< printf-style format command
     ...                                ///< trace message arguments
+#ifdef __GNUC__
 ) __attribute__((format(printf, 6, 7)));
-#else // __GNUC__
-void p_psTrace(
-    const char* file,                  ///< file name
-    int lineno,                        ///< line number in file
-    const char* func,                  ///< function name
-    const char *facil,                 ///< facilty of interest
-    psS32 level,                       ///< desired trace level
-    const char *format,                ///< printf-style format command
-    ...                                ///< trace message arguments
+#else // ifdef __GNUC__
 );
-#endif // __GNUC__
+#endif // ifdef __GNUC__
+#ifndef SWIG
+#define psTrace(facil, level, ...) \
+      p_psTrace(__FILE__,__LINE__,__func__,facil, level, __VA_ARGS__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Get the trace level
@@ -127,4 +116,9 @@
  *  @return int:    Trace Level
  */
+#ifdef DOXYGEN
+int psTraceGetLevel(
+    const char *facil                  ///< facilty of interest
+);
+#else // ifdef DOXYGEN
 int p_psTraceGetLevel(
     const char* file,                  ///< file name
@@ -133,8 +127,12 @@
     const char *facil                  ///< facilty of interest
 );
+#ifndef SWIG
+#define psTraceGetLevel(facil) \
+      p_psTraceGetLevel(__FILE__,__LINE__,__func__,facil)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
 
-#ifndef SWIG
-#define psTrace(facil, level, ...) p_psTrace(__FILE__,__LINE__,__func__,facil, level, __VA_ARGS__)
-#define psTraceGetLevel(facil) p_psTraceGetLevel(__FILE__,__LINE__,__func__,facil)
+
+
 /** Sends a trace message. */
 void psTraceV(
@@ -144,6 +142,5 @@
     va_list ap                         ///< varargs argument list
 );
-#endif /* SWIG */
-#endif /* DOXYGEN */
+
 
 /** Set trace level
@@ -159,6 +156,8 @@
 void psTraceReset(void);
 
+
 /// print trace levels
 void psTracePrintLevels(void);
+
 
 /// Set the destination of future trace messages.
@@ -166,4 +165,5 @@
     int fd                             ///< File descriptor
 );
+
 
 /** Get the current destination for trace messages.
@@ -173,6 +173,8 @@
 int psTraceGetDestination(void);
 
+
 /// Return a psMetadata summarising the trace levels
 psMetadata *psTraceLevels(void);
+
 
 /// @}
Index: /trunk/psLib/src/sys/psType.h
===================================================================
--- /trunk/psLib/src/sys/psType.h	(revision 11693)
+++ /trunk/psLib/src/sys/psType.h	(revision 11694)
@@ -10,6 +10,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-02-06 21:36:09 $
+*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-02-08 01:59:28 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -59,4 +59,5 @@
 psC32;
 
+
 /** 64-bit complex value */
 typedef struct
@@ -65,4 +66,5 @@
 }
 psC64;
+
 
 #else // SWIG
