Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision a80fbdfe7ff2c5de6edfc1365430bcadc4e1a6a3)
+++ src/config.cpp	(revision 41194a7bf06101702d6e0b8243fa47ade9e8c24e)
@@ -6,4 +6,5 @@
 
 #include "config.hpp"
+#include "memoryallocator.hpp"
 
 /******************************** Functions for class ConfigFileBuffer **********************/
@@ -86,5 +87,5 @@
     return;
   } else
-    buffer = (char **) Malloc(sizeof(char *)*NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");
+    buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");
 
   // scan each line and put into buffer
@@ -92,5 +93,5 @@
   int i;
   do {
-    buffer[lines] = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");
+    buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");
     file->getline(buffer[lines], MAXSTRINGSIZE-1);
     i = strlen(buffer[lines]);
@@ -112,7 +113,7 @@
 {
   for(int i=0;i<NoLines;++i)
-    Free((void **)&buffer[i], "ConfigFileBuffer::~ConfigFileBuffer: *buffer[]");
-  Free((void **)&buffer, "ConfigFileBuffer::~ConfigFileBuffer: **buffer");
-  Free((void **)&LineMapping, "ConfigFileBuffer::~ConfigFileBuffer: *LineMapping");
+    Free(&buffer[i]);
+  Free(&buffer);
+  Free(&LineMapping);
 }
 
@@ -122,5 +123,5 @@
 void ConfigFileBuffer::InitMapping()
 {
-  LineMapping = (int *) Malloc(sizeof(int)*NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");
+  LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");
   for (int i=0;i<NoLines;i++)
     LineMapping[i] = i;
@@ -163,14 +164,14 @@
 config::config()
 {
-  mainname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname");
-  defaultpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: defaultpath");
-  pseudopotpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: pseudopotpath");
-  databasepath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: databasepath");
-  configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configpath");
-  configname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configname");
-  ThermostatImplemented = (int *) Malloc((MaxThermostats)*(sizeof(int)), "config constructor: *ThermostatImplemented");
-  ThermostatNames = (char **) Malloc((MaxThermostats)*(sizeof(char *)), "config constructor: *ThermostatNames");
+  mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");
+  defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");
+  pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");
+  databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");
+  configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");
+  configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");
+  ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");
+  ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");
   for (int j=0;j<MaxThermostats;j++)
-    ThermostatNames[j] = (char *) MallocString(12*(sizeof(char)), "config constructor: ThermostatNames[]");
+    ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
   Thermostat = 4;
   alpha = 0.;
@@ -263,14 +264,14 @@
 config::~config()
 {
-  Free((void **)&mainname, "config::~config: *mainname");
-  Free((void **)&defaultpath, "config::~config: *defaultpath");
-  Free((void **)&pseudopotpath, "config::~config: *pseudopotpath");
-  Free((void **)&databasepath, "config::~config: *databasepath");
-  Free((void **)&configpath, "config::~config: *configpath");
-  Free((void **)&configname, "config::~config: *configname");
-  Free((void **)&ThermostatImplemented, "config::~config: *ThermostatImplemented");
+  Free(&mainname);
+  Free(&defaultpath);
+  Free(&pseudopotpath);
+  Free(&databasepath);
+  Free(&configpath);
+  Free(&configname);
+  Free(&ThermostatImplemented);
   for (int j=0;j<MaxThermostats;j++)
-    Free((void **)&ThermostatNames[j], "config::~config: *ThermostatNames[]");
-  Free((void **)&ThermostatNames, "config::~config: **ThermostatNames");
+    Free(&ThermostatNames[j]);
+  Free(&ThermostatNames);
 };
 
@@ -280,5 +281,5 @@
 void config::InitThermostats(class ConfigFileBuffer *fb)
 {
-  char *thermo = MallocString(12, "IonsInitRead: thermo");
+  char *thermo = Malloc<char>(12, "IonsInitRead: thermo");
   int verbose = 0;
 
@@ -347,5 +348,5 @@
     Thermostat = None;
   }
-  Free((void **)&thermo, "InitThermostats: thermo");
+  Free(&thermo);
 };
 
@@ -1533,5 +1534,5 @@
   long file_position = file->tellg(); // mark current position
   char *dummy1, *dummy, *free_dummy;    // pointers in the line that is read in per step
-  dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char), "config::ParseForParameter: *free_dummy");
+  dummy1 = free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");
 
   //fprintf(stderr,"Parsing for %s\n",name);
@@ -1548,5 +1549,5 @@
       if (file->eof()) {
         if ((critical) && (found == 0)) {
-          Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+          Free(&free_dummy);
           //Error(InitReading, name);
           fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
@@ -1556,5 +1557,5 @@
           file->clear();
           file->seekg(file_position, ios::beg);  // rewind to start position
-          Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+          Free(&free_dummy);
           return 0;
         }
@@ -1608,5 +1609,5 @@
               if (file->eof()) {
                 if ((critical) && (found == 0)) {
-                  Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+                  Free(&free_dummy);
                   //Error(InitReading, name);
                   fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
@@ -1616,5 +1617,5 @@
                   file->clear();
                   file->seekg(file_position, ios::beg);  // rewind to start position
-                  Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+                  Free(&free_dummy);
                   return 0;
                 }
@@ -1657,5 +1658,5 @@
                   if (critical) {
                     if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
-                    Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+                    Free(&free_dummy);
                     //return 0;
                     exit(255);
@@ -1665,5 +1666,5 @@
                     file->clear();
                     file->seekg(file_position, ios::beg);  // rewind to start position
-                    Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+                    Free(&free_dummy);
                     return 0;
                   }
@@ -1678,5 +1679,5 @@
                   file->seekg(file_position, ios::beg);  // rewind to start position
                 }
-                Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+                Free(&free_dummy);
                 return 0;
               }
@@ -1732,6 +1733,7 @@
     }
   }
-  if ((type >= row_int) && (verbose)) fprintf(stderr,"\n");
-  Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
+  if ((type >= row_int) && (verbose))
+    fprintf(stderr,"\n");
+  Free(&free_dummy);
   if (!sequential) {
     file->clear();
@@ -1811,5 +1813,5 @@
         dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
         //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
-        //Free((void **)&free_dummy);
+        //Free(&free_dummy);
         //Error(FileOpenParams, NULL);
       } else {
