Index: libroar/config.c
===================================================================
--- libroar/config.c	(revision 4784)
+++ libroar/config.c	(revision 4957)
@@ -335,7 +335,7 @@
 
  if ( config->codecs.num == 0 ) {
-  config->codecs.codec = malloc(16*sizeof(struct roar_libroar_config_codec));
+  config->codecs.codec = roar_mm_malloc(16*sizeof(struct roar_libroar_config_codec));
  } else {
-  config->codecs.codec = realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec));
+  config->codecs.codec = roar_mm_realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec));
  }
 
Index: libroar/meta.c
===================================================================
--- libroar/meta.c	(revision 4794)
+++ libroar/meta.c	(revision 4957)
@@ -589,5 +589,5 @@
  info->codec = -1;
 
- if ( (lc = strdup(str)) == NULL )
+ if ( (lc = roar_mm_strdup(str)) == NULL )
   return -1;
 
@@ -625,5 +625,5 @@
  }
 
- free(lc);
+ roar_mm_free(lc);
 
  return 0;
Index: plugins/roard/protocol-esound.c
===================================================================
--- plugins/roard/protocol-esound.c	(revision 4708)
+++ plugins/roard/protocol-esound.c	(revision 4957)
@@ -93,5 +93,5 @@
   if ( cur->cmd == cmd ) {
    if ( cur->datalen > 0 ) {
-    if ( (data = malloc(cur->datalen)) == NULL ) {
+    if ( (data = roar_mm_malloc(cur->datalen)) == NULL ) {
      // we will do a protocol error in case we do not drop the client
      clients_delete(client);
@@ -103,5 +103,5 @@
 
      if ( ret < 1 ) {
-      free(data);
+      roar_mm_free(data);
       clients_delete(client);
       return -1;
@@ -123,5 +123,5 @@
 
    if ( data != NULL )
-    free(data);
+    roar_mm_free(data);
 
    return r;
Index: roard/codecfilter_alaw.c
===================================================================
--- roard/codecfilter_alaw.c	(revision 4923)
+++ roard/codecfilter_alaw.c	(revision 4957)
@@ -74,5 +74,5 @@
  len /= 2;
 
- if ( (out = (char*)malloc(len)) == NULL )
+ if ( (out = (char*)roar_mm_malloc(len)) == NULL )
   return -1;
 
@@ -81,5 +81,5 @@
  len = stream_vio_s_write(s, out, len);
 
- free(out);
+ roar_mm_free(out);
 
  if ( len > 0 ) {
Index: roard/codecfilter_celt.c
===================================================================
--- roard/codecfilter_celt.c	(revision 4708)
+++ roard/codecfilter_celt.c	(revision 4957)
@@ -34,5 +34,5 @@
                                             struct roar_stream_server * info,
                                             struct roar_codecfilter   * filter) {
- struct codecfilter_celt_inst * self = malloc(sizeof(struct codecfilter_celt_inst));
+ struct codecfilter_celt_inst * self = roar_mm_malloc(sizeof(struct codecfilter_celt_inst));
  struct roar_stream * s = ROAR_STREAM(info);
 
@@ -62,25 +62,25 @@
  self->opened_decoder       = 0;
  self->s_buf                = s->info.channels * self->frame_size * 2;
- self->ibuf                 = malloc(self->s_buf);
- self->obuf                 = malloc(self->s_buf);
- self->i_rest               = malloc(self->s_buf);
- self->o_rest               = malloc(self->s_buf);
+ self->ibuf                 = roar_mm_malloc(self->s_buf);
+ self->obuf                 = roar_mm_malloc(self->s_buf);
+ self->i_rest               = roar_mm_malloc(self->s_buf);
+ self->o_rest               = roar_mm_malloc(self->s_buf);
  self->fi_rest              = 0;
  self->fo_rest              = 0;
 
  if ( !(self->ibuf && self->obuf && self->i_rest && self->o_rest) ) {
-  if ( self->ibuf )
-   free(self->ibuf);
-
-  if ( self->obuf )
-   free(self->obuf);
-
-  if ( self->i_rest )
-   free(self->o_rest);
-
-  if ( self->o_rest )
-   free(self->o_rest);
-
-  free(self);
+  if ( self->ibuf != NULL )
+   roar_mm_free(self->ibuf);
+
+  if ( self->obuf != NULL )
+   roar_mm_free(self->obuf);
+
+  if ( self->i_rest != NULL )
+   roar_mm_free(self->o_rest);
+
+  if ( self->o_rest != NULL )
+   roar_mm_free(self->o_rest);
+
+  roar_mm_free(self);
   return -1;
  }
@@ -93,5 +93,5 @@
 
  if ( !self->mode ) {
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -119,5 +119,5 @@
  } else {
   celt_mode_destroy(self->mode);
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -137,26 +137,26 @@
   return -1;
 
- if ( self->encoder )
+ if ( self->encoder != NULL )
   celt_encoder_destroy(self->encoder);
 
- if ( self->decoder )
+ if ( self->decoder != NULL )
   celt_decoder_destroy(self->decoder);
 
- if ( self->mode )
+ if ( self->mode != NULL )
   celt_mode_destroy(self->mode);
 
- if ( self->ibuf )
-  free(self->ibuf);
-
- if ( self->obuf )
-  free(self->obuf);
-
- if ( self->i_rest )
-  free(self->i_rest);
-
- if ( self->o_rest )
-  free(self->o_rest);
-
- free(inst);
+ if ( self->ibuf != NULL )
+  roar_mm_free(self->ibuf);
+
+ if ( self->obuf != NULL )
+  roar_mm_free(self->obuf);
+
+ if ( self->i_rest != NULL )
+  roar_mm_free(self->i_rest);
+
+ if ( self->o_rest != NULL )
+  roar_mm_free(self->o_rest);
+
+ roar_mm_free(inst);
  return 0;
 }
Index: roard/codecfilter_fishsound.c
===================================================================
--- roard/codecfilter_fishsound.c	(revision 4708)
+++ roard/codecfilter_fishsound.c	(revision 4957)
@@ -102,5 +102,5 @@
                                             struct roar_stream_server * info,
                                             struct roar_codecfilter   * filter) {
- struct codecfilter_fishsound_inst * self = malloc(sizeof(struct codecfilter_fishsound_inst));
+ struct codecfilter_fishsound_inst * self = roar_mm_malloc(sizeof(struct codecfilter_fishsound_inst));
  struct roar_stream * s = ROAR_STREAM(info);
 
@@ -109,5 +109,5 @@
 
  if ( s->dir != ROAR_DIR_PLAY ) {
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -142,5 +142,5 @@
   roar_buffer_free(self->buffer);
 
- free(inst);
+ roar_mm_free(inst);
  return 0;
 }
Index: roard/codecfilter_mulaw.c
===================================================================
--- roard/codecfilter_mulaw.c	(revision 4923)
+++ roard/codecfilter_mulaw.c	(revision 4957)
@@ -74,5 +74,5 @@
  len /= 2;
 
- if ( (out = (char*)malloc(len)) == NULL )
+ if ( (out = (char*)roar_mm_malloc(len)) == NULL )
   return -1;
 
@@ -81,5 +81,5 @@
  len = stream_vio_s_write(s, out, len);
 
- free(out);
+ roar_mm_free(out);
 
  if ( len > 0 ) {
Index: roard/codecfilter_sndfile.c
===================================================================
--- roard/codecfilter_sndfile.c	(revision 4708)
+++ roard/codecfilter_sndfile.c	(revision 4957)
@@ -33,5 +33,5 @@
  struct codecfilter_sndfile_inst * obj;
 
- if ( (obj = (struct codecfilter_sndfile_inst *) malloc(sizeof(struct codecfilter_sndfile_inst))) == NULL )
+ if ( (obj = (struct codecfilter_sndfile_inst *) roar_mm_malloc(sizeof(struct codecfilter_sndfile_inst))) == NULL )
   return -1;
 
@@ -60,5 +60,5 @@
   sf_close(obj->state);
 
- free(obj);
+ roar_mm_free(obj);
 
  return 0;
Index: roard/codecfilter_speex.c
===================================================================
--- roard/codecfilter_speex.c	(revision 4708)
+++ roard/codecfilter_speex.c	(revision 4957)
@@ -46,5 +46,5 @@
                                             struct roar_stream_server * info,
                                             struct roar_codecfilter   * filter) {
- struct codecfilter_speex_inst * self = malloc(sizeof(struct codecfilter_speex_inst));
+ struct codecfilter_speex_inst * self = roar_mm_malloc(sizeof(struct codecfilter_speex_inst));
  struct roar_stream * s = ROAR_STREAM(info);
 
@@ -61,5 +61,5 @@
   case 2: self->stereo = 1; break;
   default:
-    free(self);
+    roar_mm_free(self);
     return -1;
  }
@@ -111,11 +111,11 @@
  speex_bits_destroy(&(self->bits));
 
- if ( self->cd )
-  free(self->cd);
-
- if ( self->i_rest )
-  free(self->i_rest);
-
- free((void*)self);
+ if ( self->cd != NULL )
+  roar_mm_free(self->cd);
+
+ if ( self->i_rest != NULL )
+  roar_mm_free(self->i_rest);
+
+ roar_mm_free((void*)self);
 
  return 0;
@@ -171,13 +171,13 @@
   ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2);
 
-  if ( !self->cd ) {
-   self->cd = malloc(fs2);
-   if ( !self->cd )
+  if ( self->cd == NULL ) {
+   self->cd = roar_mm_malloc(fs2);
+   if ( self->cd == NULL )
     return 0;
   }
 
-  if ( !self->i_rest ) {
-   self->i_rest = malloc(fs2);
-   if ( !self->i_rest )
+  if ( self->i_rest == NULL ) {
+   self->i_rest = roar_mm_malloc(fs2);
+   if ( self->i_rest == NULL )
     return 0;
   }
@@ -334,13 +334,13 @@
   fs2 = self->frame_size * _FS;
 
-  if ( !self->cd ) {
-   self->cd = malloc(fs2 + 2);
-   if ( !self->cd )
+  if ( self->cd == NULL ) {
+   self->cd = roar_mm_malloc(fs2 + 2);
+   if ( self->cd == NULL )
     return 0;
   }
 
-  if ( !self->o_rest ) {
-   self->o_rest = malloc(fs2);
-   if ( !self->o_rest )
+  if ( self->o_rest == NULL ) {
+   self->o_rest = roar_mm_malloc(fs2);
+   if ( self->o_rest == NULL )
     return 0;
   }
Index: roard/container_framework.c
===================================================================
--- roard/container_framework.c	(revision 4708)
+++ roard/container_framework.c	(revision 4957)
@@ -43,5 +43,5 @@
   return -1;
 
- if ( (self = malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) {
+ if ( (self = roar_mm_malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) {
   *inst = NULL;
   return -1;
@@ -54,5 +54,5 @@
 
  if ( cont_pvio_open(&(self->vio), self) == -1 ) {
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -85,5 +85,5 @@
   inst->pcb.close(inst);
 
- free(inst);
+ roar_mm_free(inst);
 
  ROAR_DBG("cont_fw_delete(inst=%p) = 0", inst);
@@ -135,5 +135,5 @@
   return -1;
 
- if ( (self = malloc(sizeof(struct cont_fw_child_vio_inst))) == NULL )
+ if ( (self = roar_mm_malloc(sizeof(struct cont_fw_child_vio_inst))) == NULL )
   return -1;
 
@@ -149,5 +149,5 @@
   if ( inst->pcb.new_child(inst, self) == -1 ) {
    inst->child[i] = NULL;
-   free(self);
+   roar_mm_free(self);
    return -1;
   }
@@ -229,5 +229,5 @@
  }
 
- free(inst);
+ roar_mm_free(inst);
 
  return  r;
Index: roard/driver_oss.c
===================================================================
--- roard/driver_oss.c	(revision 4846)
+++ roard/driver_oss.c	(revision 4957)
@@ -345,10 +345,10 @@
 }
 
-#define er() close(self->fh); if ( self->device ) free(self->device); free(self); return -1
+#define er() close(self->fh); if ( self->device ) roar_mm_free(self->device); roar_mm_free(self); return -1
 int driver_oss_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
  struct driver_oss * self = NULL;
 
- if ( (self = malloc(sizeof(struct driver_oss))) == NULL ) {
-  ROAR_ERR("driver_oss_open(*): Can not malloc() instance data: %s", strerror(errno));
+ if ( (self = roar_mm_malloc(sizeof(struct driver_oss))) == NULL ) {
+  ROAR_ERR("driver_oss_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno));
   return -1;
  }
@@ -370,5 +370,5 @@
 
  if ( device != NULL )
-  self->device = strdup(device);
+  self->device = roar_mm_strdup(device);
 
  if ( driver_oss_init_vio(inst, self) == -1 ) {
@@ -419,7 +419,7 @@
 
  if ( _get(vio,device) != NULL )
-  free(_get(vio,device));
-
- free(vio->inst);
+  roar_mm_free(_get(vio,device));
+
+ roar_mm_free(vio->inst);
  return 0;
 }
Index: roard/driver_pwmled.c
===================================================================
--- roard/driver_pwmled.c	(revision 4708)
+++ roard/driver_pwmled.c	(revision 4957)
@@ -30,5 +30,5 @@
 int driver_pwmled_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
  struct roar_vio_defaults def;
- struct driver_pwmled * self = malloc(sizeof(struct driver_pwmled));
+ struct driver_pwmled * self = roar_mm_malloc(sizeof(struct driver_pwmled));
 
  if ( self == NULL )
@@ -40,10 +40,10 @@
 
   if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 ) {
-   free(self);
+   roar_mm_free(self);
    return -1;
   }
 
   if ( roar_vio_open_dstr(&(self->vio), device, &def, 1) == -1 ) {
-   free(self);
+   roar_mm_free(self);
    return -1;
   }
@@ -55,5 +55,5 @@
    return -1;
 */
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -78,5 +78,5 @@
 
  if ( roar_light_pwm_new(&(self->state), 16) == -1 ) {
-  free(self);
+  roar_mm_free(self);
   return -1;
  }
@@ -92,5 +92,5 @@
 
  if ( vio->inst != NULL )
-  free(vio->inst);
+  roar_mm_free(vio->inst);
 
  return ret;
Index: roard/driver_sndio.c
===================================================================
--- roard/driver_sndio.c	(revision 4708)
+++ roard/driver_sndio.c	(revision 4957)
@@ -52,6 +52,6 @@
  struct driver_sndio * self = NULL;
 
- if ( (self = malloc(sizeof(struct driver_sndio))) == NULL ) {
-  ROAR_ERR("driver_sndio_open(*): Can not malloc() instance data: %s", strerror(errno));
+ if ( (self = roar_mm_malloc(sizeof(struct driver_sndio))) == NULL ) {
+  ROAR_ERR("driver_sndio_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno));
   return -1;
  }
@@ -85,5 +85,5 @@
 
  if ( device != NULL )
-  self->device = strdup(device);
+  self->device = roar_mm_strdup(device);
 
  if ( driver_sndio_init_vio(inst, self) == -1 ) {
@@ -113,7 +113,7 @@
 
  if ( self->device != NULL )
-  free(self->device);
-
- free(self);
+  roar_mm_free(self->device);
+
+ roar_mm_free(self);
 
  return 0;
Index: roard/driver_wmm.c
===================================================================
--- roard/driver_wmm.c	(revision 4708)
+++ roard/driver_wmm.c	(revision 4957)
@@ -35,5 +35,5 @@
   MMRESULT mmres;
 
-  self->bigbuffer = malloc(bytes);
+  self->bigbuffer = roar_mm_malloc(bytes);
   if (self->bigbuffer != NULL) {
     int i;
@@ -60,5 +60,5 @@
                                &self->wh[i].wh,sizeof(WAVEHDR));
       }
-      free(self->bigbuffer);
+      roar_mm_free(self->bigbuffer);
       self->wh        = 0;
       self->spl       = 0;
@@ -182,5 +182,5 @@
  MMRESULT mmres;
 
- if ( (self = malloc(sizeof(struct driver_wmm))) == NULL )
+ if ( (self = roar_mm_malloc(sizeof(struct driver_wmm))) == NULL )
   return -1;
 
@@ -252,5 +252,5 @@
  }
 
- free(self);
+ roar_mm_free(self);
 
  ROAR_DBG("driver_wmm_close_vio(*) = 0");
Index: roard/light.c
===================================================================
--- roard/light.c	(revision 4708)
+++ roard/light.c	(revision 4957)
@@ -37,10 +37,10 @@
   return -1;
 
- if ( (g_light_state.state = malloc(channels)) == NULL ) {
-  return -1;
- }
-
- if ( (g_light_state.changes = malloc(channels)) == NULL ) {
-  free(g_light_state.state);
+ if ( (g_light_state.state = roar_mm_malloc(channels)) == NULL ) {
+  return -1;
+ }
+
+ if ( (g_light_state.changes = roar_mm_malloc(channels)) == NULL ) {
+  roar_mm_free(g_light_state.state);
   return -1;
  }
@@ -49,5 +49,5 @@
 
  if ( (g_light_mixer.stream = add_mixer(ROAR_SUBSYS_LIGHT, _MIXER_NAME("Light Control"), &ss)) == -1 ) {
-  free(g_light_state.state);
+  roar_mm_free(g_light_state.state);
   return -1;
  }
@@ -70,9 +70,9 @@
 int light_free  (void) {
  if ( g_light_state.state != NULL ) {
-  free(g_light_state.state);
+  roar_mm_free(g_light_state.state);
  }
 
  if ( g_light_state.changes != NULL ) {
-  free(g_light_state.changes);
+  roar_mm_free(g_light_state.changes);
  }
 
Index: roard/sample.c
===================================================================
--- roard/sample.c	(revision 4708)
+++ roard/sample.c	(revision 4957)
@@ -47,5 +47,5 @@
 
 int samples_new       (void) {
- struct roar_sample * c = malloc(sizeof(struct roar_sample));
+ struct roar_sample * c = roar_mm_malloc(sizeof(struct roar_sample));
  int i;
 
@@ -63,5 +63,5 @@
  }
 
- free(c);
+ roar_mm_free(c);
 
  return -1;
Index: roard/streams.c
===================================================================
--- roard/streams.c	(revision 4934)
+++ roard/streams.c	(revision 4957)
@@ -372,5 +372,5 @@
 
  if ( s->output != NULL )
-  free(s->output);
+  roar_mm_free(s->output);
 
 /*
@@ -386,5 +386,5 @@
 
  if ( s->name != NULL )
-  free(s->name);
+  roar_mm_free(s->name);
 
  roar_mm_free(s);
@@ -1336,9 +1336,9 @@
  _CHECK_SID(id);
 
- if ( (str = strdup(name)) == NULL )
+ if ( (str = roar_mm_strdup(name)) == NULL )
   return -1;
 
  if ( g_streams[id]->name != NULL )
-  free(g_streams[id]->name);
+  roar_mm_free(g_streams[id]->name);
 
  g_streams[id]->name = str;
@@ -1722,5 +1722,5 @@
  }
 
- if ( (g_streams[id]->output = malloc(size)) == NULL ) {
+ if ( (g_streams[id]->output = roar_mm_malloc(size)) == NULL ) {
   ROAR_ERR("streams_get_outputbuffer(*): Can not alloc: %s", strerror(errno));
   return -1;
