Index: trunk/ppImage/src/ppImage.c
===================================================================
--- trunk/ppImage/src/ppImage.c	(revision 6148)
+++ trunk/ppImage/src/ppImage.c	(revision 6260)
@@ -1,71 +1,42 @@
+#include <stdio.h>
+#include "pslib.h"
 #include "ppImage.h"
-
-psMemId ppMemAlloc(const psMemBlock *ptr)
-{
-    psLogMsg(__func__, PS_LOG_INFO,
-             "Allocated memory block %d: %ld references\n"
-             "\tFile %s, line %d, size %d\n"
-             "\tPosts: %lx %lx %lx\n"
-             "\tLast operation: %s:%d\n",
-             ptr->id, ptr->refCounter, ptr->file, ptr->lineno, ptr->userMemorySize, ptr->startblock,
-             ptr->endblock, *(void**)((int8_t *)(ptr + 1) + ptr->userMemorySize),
-             ptr->lastopFile, ptr->lastopLine);
-    return 0;
-}
-
-psMemId ppMemFree(const psMemBlock *ptr)
-{
-    psLogMsg(__func__, PS_LOG_INFO,
-             "Freed memory block %d: %ld references\n"
-             "\tFile %s, line %d, size %d\n"
-             "\tPosts: %lx %lx %lx\n"
-             "\tLast operation: %s:%d\n",
-             ptr->id, ptr->refCounter-1, ptr->file, ptr->lineno, ptr->userMemorySize, ptr->startblock,
-             ptr->endblock, *(void**)((int8_t *)(ptr + 1) + ptr->userMemorySize),
-             ptr->lastopFile, ptr->lastopLine);
-    return 0;
-}
+#include "ppMem.h"
 
 
 int main(int argc, char **argv)
 {
-#if 0
-    psMemAllocCallbackSet(ppMemAlloc);
-    psMemFreeCallbackSet(ppMemFree);
-//    psMemAllocCallbackSetID(6967);
-//    psMemFreeCallbackSetID(6967);
-    psMemAllocCallbackSetID(51804);
-    psMemFreeCallbackSetID(51804);
-#endif
+//    psErrorRegister(NULL, -1);
 
-    ppData data;
-    ppConfig config;
-    ppOptions options;
+    ppImageData *data = ppImageDataAlloc();
+    ppImageOptions *options = ppImageOptionsAlloc();
+    ppConfig *config = ppConfigAlloc();
 
     psTimerStart(TIMERNAME);
 
     // Parse the configuration and arguments
-    ppImageConfig(&config, argc, argv);
+    ppImageConfig(config, argc, argv);
 
     // Open the input image, output image, output mask
     // Get camera configuration from header if not already defined
     // Construct camera in preparation for reading
-    ppImageParseCamera(&data, &config);
+    ppImageParseCamera(data, config);
+
+    // Cleaning up
+    psFree(data);
+    psFree(options);
+    psFree(config);
+    psTimerStop();
+    ppMemCheck();
+#if 0
 
     // Set various tasks (define optional operations)
-    ppImageOptions(&data, &options, &config);
+    ppImageOptionsParse(data, options, config);
 
     // open detrend images, load headers, optionally load pixels
-    ppImageParseDetrend(&data, &options, &config);
+    ppImageParseDetrend(data, options, config);
 
     // Image Arithmetic Loop
-    ppImageLoop(&data, &options, &config);
-
-#if 0
-    // Output image
-    ppImageOutput(&data, &config);
-
-    // Do photometry
-    ppImagePhot(&data, &options, &config);
+    ppImageLoop(data, options, config);
 #endif
 
