Index: trunk/src/cee/rappture_interface.c
===================================================================
--- trunk/src/cee/rappture_interface.c	(revision 47)
+++ trunk/src/cee/rappture_interface.c	(revision 49)
@@ -187,6 +187,7 @@
  *          1) the return object will need to be cast as a char*
  *             to use it.
+ *          2) It is the caller's responsibility to free the returned pointer
  *        
- *        The Arguments lib and pathare not optional.
+ *        The Arguments lib and path are not optional.
  *          If either value is NULL, NULL will be returned.
  *
@@ -200,5 +201,8 @@
     PyObject* mbr_fxn   = NULL;      /* pointer to fxn of class lib */
     PyObject* rslt      = NULL;      /* results from fxn call */
+    char* tmpRetVal     = NULL;      /* fxn return value */
+    char* tmpString     = NULL;      /* fxn return value */
     void* retVal        = NULL;      /* fxn return value */
+    int retValSize      = 0;
 
     if (lib && path) {
@@ -236,5 +240,18 @@
                         // return a char*
                         // convert the result to c style strings
-                        retVal = (void*) PyString_AsString(rslt);
+                        // retVal = (void*) PyString_AsString(rslt);
+                        tmpRetVal = PyString_AsString(rslt);
+                        if (tmpRetVal) {
+                            // get str length, add 1 for null termination
+                            retValSize = strlen(tmpRetVal) + 1;
+                            tmpString = (char*) calloc(retValSize,sizeof(char));
+                            if (tmpString) {
+                                strncpy(tmpString,tmpRetVal,retValSize);
+                                retVal = (void*) tmpString;
+                            }
+                            else {
+                                // raise error, out of memory
+                            } 
+                        }
                         Py_DECREF(rslt);
                     }
@@ -280,4 +297,6 @@
  *          1) the return object will need to be case as a char*
  *             to use it.
+ *          2) It is the caller's responsibility to free the contents of 
+ *              the returned pointer (ie. free(*retVal))
  *        
  *        The Arguments lib and pathare not optional.
@@ -299,4 +318,8 @@
     char** rslt_arr_c   = NULL;
     void** rslt_arr  = NULL;
+    char*  tmpRetVal    = NULL;
+    char*  tmpString    = 0;
+    int retValSize      = 0;
+    
 
     if (lib && path) {
@@ -373,6 +396,20 @@
                                 // we cannot deallocate the results of 
                                 // PyString_AsString()
-                                rslt_arr_c[index] = PyString_AsString(list_item);
-                                index++;
+
+                                tmpRetVal = PyString_AsString(list_item);
+                                if (tmpRetVal) {
+                                    // get str length, add 1 for null termination
+                                    retValSize = strlen(tmpRetVal) + 1;
+                                    tmpString = (char*) calloc(retValSize,sizeof(char));
+                                    if (tmpString) {
+                                        strncpy(tmpString,tmpRetVal,retValSize);
+                                        rslt_arr_c[index] = tmpString;
+                                        tmpString = NULL;
+                                        index++;
+                                    }
+                                }
+
+                                // rslt_arr_c[index] = PyString_AsString(list_item);
+                                // index++;
                                 
                             }
@@ -517,17 +554,19 @@
  *          NULL will be returned.
  *
- * Returns pointer (const char*) to the c style string representing the
+ * Returns pointer (char*) to the c style string representing the
  *          xml text provided by the path of the Rappture object if 
  *          successful, or NULL if something goes wrong.
  *
- *          The return value's contents should not be changed because 
- *          it is a pointer being borrowed from python's buffer space
- *          (hence the _const_)
- */
-const char* rpGet(PyObject* lib, const char* path)
+ *          It is the responsibility of the caller to free the 
+ *          returned pointer
+ *
+ */
+char* rpGet(PyObject* lib, const char* path)
 {
     PyObject* mbr_fxn   = NULL;      /* pointer to fxn of class lib */
     PyObject* rslt      = NULL;      /* results from fxn call */
+    char* tmpRetVal     = NULL;      /* return value */
     char* retVal        = NULL;      /* return value */
+    int retValSize      = 0;
 
     if (lib) {
@@ -543,6 +582,19 @@
                 if (rslt) {
                     // convert the result to c style strings
-                    retVal = PyString_AsString(rslt);
-                    // Py_DECREF(rslt);
+                    tmpRetVal = PyString_AsString(rslt);
+
+                    if (tmpRetVal) {
+                        // get str length, add 1 for null termination
+                        retValSize = strlen(tmpRetVal) + 1;
+                        retVal = (char*) calloc(retValSize,sizeof(char));
+                        if (retVal) {
+                            strncpy(retVal,tmpRetVal,retValSize);
+                        }
+                        else {
+                            // raise error, out of memory
+                        }                           
+                    }
+
+                    Py_DECREF(rslt);
                 }
                 
@@ -555,5 +607,5 @@
     }
 
-    return (const char*) retVal;
+    return retVal;
     
 }
@@ -737,4 +789,5 @@
     char* tmpretVal     = NULL;      /* return value */
     char* retVal        = NULL;      /* return value */
+    int retValSize      = 0;
 
     if (lib) {
@@ -751,6 +804,15 @@
                     // convert the result to c style strings
                     tmpretVal = PyString_AsString(rslt);
-                    retVal = (char*) calloc(strlen(tmpretVal),sizeof(char));
-                    strcpy(retVal,tmpretVal);
+                    if (tmpretVal) {
+                        // get str length, add 1 for null termination
+                        retValSize = strlen(tmpretVal) + 1;
+                        retVal = (char*) calloc(retValSize,sizeof(char));
+                        if (retVal) {
+                            strncpy(retVal,tmpretVal,retValSize);
+                        }
+                        else {
+                            // raise error, out of memory
+                        }
+                    }
                     Py_DECREF(rslt);
                 }
Index: trunk/src/fortran/rappture_fortran.c
===================================================================
--- trunk/src/fortran/rappture_fortran.c	(revision 47)
+++ trunk/src/fortran/rappture_fortran.c	(revision 49)
@@ -514,5 +514,7 @@
                         }
                         *(retText+length_out-1) = ' ';
-
+                        
+                        free(retObj);
+                        retObj = NULL;
                     }
                     else {
