Changeset 4957:45ba4cf2abe3 in roaraudio


Ignore:
Timestamp:
05/13/11 23:30:17 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

use roar_mm_*() where possible

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • libroar/config.c

    r4784 r4957  
    335335 
    336336 if ( config->codecs.num == 0 ) { 
    337   config->codecs.codec = malloc(16*sizeof(struct roar_libroar_config_codec)); 
     337  config->codecs.codec = roar_mm_malloc(16*sizeof(struct roar_libroar_config_codec)); 
    338338 } else { 
    339   config->codecs.codec = realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec)); 
     339  config->codecs.codec = roar_mm_realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec)); 
    340340 } 
    341341 
  • libroar/meta.c

    r4794 r4957  
    589589 info->codec = -1; 
    590590 
    591  if ( (lc = strdup(str)) == NULL ) 
     591 if ( (lc = roar_mm_strdup(str)) == NULL ) 
    592592  return -1; 
    593593 
     
    625625 } 
    626626 
    627  free(lc); 
     627 roar_mm_free(lc); 
    628628 
    629629 return 0; 
  • plugins/roard/protocol-esound.c

    r4708 r4957  
    9393  if ( cur->cmd == cmd ) { 
    9494   if ( cur->datalen > 0 ) { 
    95     if ( (data = malloc(cur->datalen)) == NULL ) { 
     95    if ( (data = roar_mm_malloc(cur->datalen)) == NULL ) { 
    9696     // we will do a protocol error in case we do not drop the client 
    9797     clients_delete(client); 
     
    103103 
    104104     if ( ret < 1 ) { 
    105       free(data); 
     105      roar_mm_free(data); 
    106106      clients_delete(client); 
    107107      return -1; 
     
    123123 
    124124   if ( data != NULL ) 
    125     free(data); 
     125    roar_mm_free(data); 
    126126 
    127127   return r; 
  • roard/codecfilter_alaw.c

    r4923 r4957  
    7474 len /= 2; 
    7575 
    76  if ( (out = (char*)malloc(len)) == NULL ) 
     76 if ( (out = (char*)roar_mm_malloc(len)) == NULL ) 
    7777  return -1; 
    7878 
     
    8181 len = stream_vio_s_write(s, out, len); 
    8282 
    83  free(out); 
     83 roar_mm_free(out); 
    8484 
    8585 if ( len > 0 ) { 
  • roard/codecfilter_celt.c

    r4708 r4957  
    3434                                            struct roar_stream_server * info, 
    3535                                            struct roar_codecfilter   * filter) { 
    36  struct codecfilter_celt_inst * self = malloc(sizeof(struct codecfilter_celt_inst)); 
     36 struct codecfilter_celt_inst * self = roar_mm_malloc(sizeof(struct codecfilter_celt_inst)); 
    3737 struct roar_stream * s = ROAR_STREAM(info); 
    3838 
     
    6262 self->opened_decoder       = 0; 
    6363 self->s_buf                = s->info.channels * self->frame_size * 2; 
    64  self->ibuf                 = malloc(self->s_buf); 
    65  self->obuf                 = malloc(self->s_buf); 
    66  self->i_rest               = malloc(self->s_buf); 
    67  self->o_rest               = malloc(self->s_buf); 
     64 self->ibuf                 = roar_mm_malloc(self->s_buf); 
     65 self->obuf                 = roar_mm_malloc(self->s_buf); 
     66 self->i_rest               = roar_mm_malloc(self->s_buf); 
     67 self->o_rest               = roar_mm_malloc(self->s_buf); 
    6868 self->fi_rest              = 0; 
    6969 self->fo_rest              = 0; 
    7070 
    7171 if ( !(self->ibuf && self->obuf && self->i_rest && self->o_rest) ) { 
    72   if ( self->ibuf ) 
    73    free(self->ibuf); 
    74  
    75   if ( self->obuf ) 
    76    free(self->obuf); 
    77  
    78   if ( self->i_rest ) 
    79    free(self->o_rest); 
    80  
    81   if ( self->o_rest ) 
    82    free(self->o_rest); 
    83  
    84   free(self); 
     72  if ( self->ibuf != NULL ) 
     73   roar_mm_free(self->ibuf); 
     74 
     75  if ( self->obuf != NULL ) 
     76   roar_mm_free(self->obuf); 
     77 
     78  if ( self->i_rest != NULL ) 
     79   roar_mm_free(self->o_rest); 
     80 
     81  if ( self->o_rest != NULL ) 
     82   roar_mm_free(self->o_rest); 
     83 
     84  roar_mm_free(self); 
    8585  return -1; 
    8686 } 
     
    9393 
    9494 if ( !self->mode ) { 
    95   free(self); 
     95  roar_mm_free(self); 
    9696  return -1; 
    9797 } 
     
    119119 } else { 
    120120  celt_mode_destroy(self->mode); 
    121   free(self); 
     121  roar_mm_free(self); 
    122122  return -1; 
    123123 } 
     
    137137  return -1; 
    138138 
    139  if ( self->encoder ) 
     139 if ( self->encoder != NULL ) 
    140140  celt_encoder_destroy(self->encoder); 
    141141 
    142  if ( self->decoder ) 
     142 if ( self->decoder != NULL ) 
    143143  celt_decoder_destroy(self->decoder); 
    144144 
    145  if ( self->mode ) 
     145 if ( self->mode != NULL ) 
    146146  celt_mode_destroy(self->mode); 
    147147 
    148  if ( self->ibuf ) 
    149   free(self->ibuf); 
    150  
    151  if ( self->obuf ) 
    152   free(self->obuf); 
    153  
    154  if ( self->i_rest ) 
    155   free(self->i_rest); 
    156  
    157  if ( self->o_rest ) 
    158   free(self->o_rest); 
    159  
    160  free(inst); 
     148 if ( self->ibuf != NULL ) 
     149  roar_mm_free(self->ibuf); 
     150 
     151 if ( self->obuf != NULL ) 
     152  roar_mm_free(self->obuf); 
     153 
     154 if ( self->i_rest != NULL ) 
     155  roar_mm_free(self->i_rest); 
     156 
     157 if ( self->o_rest != NULL ) 
     158  roar_mm_free(self->o_rest); 
     159 
     160 roar_mm_free(inst); 
    161161 return 0; 
    162162} 
  • roard/codecfilter_fishsound.c

    r4708 r4957  
    102102                                            struct roar_stream_server * info, 
    103103                                            struct roar_codecfilter   * filter) { 
    104  struct codecfilter_fishsound_inst * self = malloc(sizeof(struct codecfilter_fishsound_inst)); 
     104 struct codecfilter_fishsound_inst * self = roar_mm_malloc(sizeof(struct codecfilter_fishsound_inst)); 
    105105 struct roar_stream * s = ROAR_STREAM(info); 
    106106 
     
    109109 
    110110 if ( s->dir != ROAR_DIR_PLAY ) { 
    111   free(self); 
     111  roar_mm_free(self); 
    112112  return -1; 
    113113 } 
     
    142142  roar_buffer_free(self->buffer); 
    143143 
    144  free(inst); 
     144 roar_mm_free(inst); 
    145145 return 0; 
    146146} 
  • roard/codecfilter_mulaw.c

    r4923 r4957  
    7474 len /= 2; 
    7575 
    76  if ( (out = (char*)malloc(len)) == NULL ) 
     76 if ( (out = (char*)roar_mm_malloc(len)) == NULL ) 
    7777  return -1; 
    7878 
     
    8181 len = stream_vio_s_write(s, out, len); 
    8282 
    83  free(out); 
     83 roar_mm_free(out); 
    8484 
    8585 if ( len > 0 ) { 
  • roard/codecfilter_sndfile.c

    r4708 r4957  
    3333 struct codecfilter_sndfile_inst * obj; 
    3434 
    35  if ( (obj = (struct codecfilter_sndfile_inst *) malloc(sizeof(struct codecfilter_sndfile_inst))) == NULL ) 
     35 if ( (obj = (struct codecfilter_sndfile_inst *) roar_mm_malloc(sizeof(struct codecfilter_sndfile_inst))) == NULL ) 
    3636  return -1; 
    3737 
     
    6060  sf_close(obj->state); 
    6161 
    62  free(obj); 
     62 roar_mm_free(obj); 
    6363 
    6464 return 0; 
  • roard/codecfilter_speex.c

    r4708 r4957  
    4646                                            struct roar_stream_server * info, 
    4747                                            struct roar_codecfilter   * filter) { 
    48  struct codecfilter_speex_inst * self = malloc(sizeof(struct codecfilter_speex_inst)); 
     48 struct codecfilter_speex_inst * self = roar_mm_malloc(sizeof(struct codecfilter_speex_inst)); 
    4949 struct roar_stream * s = ROAR_STREAM(info); 
    5050 
     
    6161  case 2: self->stereo = 1; break; 
    6262  default: 
    63     free(self); 
     63    roar_mm_free(self); 
    6464    return -1; 
    6565 } 
     
    111111 speex_bits_destroy(&(self->bits)); 
    112112 
    113  if ( self->cd ) 
    114   free(self->cd); 
    115  
    116  if ( self->i_rest ) 
    117   free(self->i_rest); 
    118  
    119  free((void*)self); 
     113 if ( self->cd != NULL ) 
     114  roar_mm_free(self->cd); 
     115 
     116 if ( self->i_rest != NULL ) 
     117  roar_mm_free(self->i_rest); 
     118 
     119 roar_mm_free((void*)self); 
    120120 
    121121 return 0; 
     
    171171  ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2); 
    172172 
    173   if ( !self->cd ) { 
    174    self->cd = malloc(fs2); 
    175    if ( !self->cd ) 
     173  if ( self->cd == NULL ) { 
     174   self->cd = roar_mm_malloc(fs2); 
     175   if ( self->cd == NULL ) 
    176176    return 0; 
    177177  } 
    178178 
    179   if ( !self->i_rest ) { 
    180    self->i_rest = malloc(fs2); 
    181    if ( !self->i_rest ) 
     179  if ( self->i_rest == NULL ) { 
     180   self->i_rest = roar_mm_malloc(fs2); 
     181   if ( self->i_rest == NULL ) 
    182182    return 0; 
    183183  } 
     
    334334  fs2 = self->frame_size * _FS; 
    335335 
    336   if ( !self->cd ) { 
    337    self->cd = malloc(fs2 + 2); 
    338    if ( !self->cd ) 
     336  if ( self->cd == NULL ) { 
     337   self->cd = roar_mm_malloc(fs2 + 2); 
     338   if ( self->cd == NULL ) 
    339339    return 0; 
    340340  } 
    341341 
    342   if ( !self->o_rest ) { 
    343    self->o_rest = malloc(fs2); 
    344    if ( !self->o_rest ) 
     342  if ( self->o_rest == NULL ) { 
     343   self->o_rest = roar_mm_malloc(fs2); 
     344   if ( self->o_rest == NULL ) 
    345345    return 0; 
    346346  } 
  • roard/container_framework.c

    r4708 r4957  
    4343  return -1; 
    4444 
    45  if ( (self = malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) { 
     45 if ( (self = roar_mm_malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) { 
    4646  *inst = NULL; 
    4747  return -1; 
     
    5454 
    5555 if ( cont_pvio_open(&(self->vio), self) == -1 ) { 
    56   free(self); 
     56  roar_mm_free(self); 
    5757  return -1; 
    5858 } 
     
    8585  inst->pcb.close(inst); 
    8686 
    87  free(inst); 
     87 roar_mm_free(inst); 
    8888 
    8989 ROAR_DBG("cont_fw_delete(inst=%p) = 0", inst); 
     
    135135  return -1; 
    136136 
    137  if ( (self = malloc(sizeof(struct cont_fw_child_vio_inst))) == NULL ) 
     137 if ( (self = roar_mm_malloc(sizeof(struct cont_fw_child_vio_inst))) == NULL ) 
    138138  return -1; 
    139139 
     
    149149  if ( inst->pcb.new_child(inst, self) == -1 ) { 
    150150   inst->child[i] = NULL; 
    151    free(self); 
     151   roar_mm_free(self); 
    152152   return -1; 
    153153  } 
     
    229229 } 
    230230 
    231  free(inst); 
     231 roar_mm_free(inst); 
    232232 
    233233 return  r; 
  • roard/driver_oss.c

    r4846 r4957  
    345345} 
    346346 
    347 #define er() close(self->fh); if ( self->device ) free(self->device); free(self); return -1 
     347#define er() close(self->fh); if ( self->device ) roar_mm_free(self->device); roar_mm_free(self); return -1 
    348348int driver_oss_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) { 
    349349 struct driver_oss * self = NULL; 
    350350 
    351  if ( (self = malloc(sizeof(struct driver_oss))) == NULL ) { 
    352   ROAR_ERR("driver_oss_open(*): Can not malloc() instance data: %s", strerror(errno)); 
     351 if ( (self = roar_mm_malloc(sizeof(struct driver_oss))) == NULL ) { 
     352  ROAR_ERR("driver_oss_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno)); 
    353353  return -1; 
    354354 } 
     
    370370 
    371371 if ( device != NULL ) 
    372   self->device = strdup(device); 
     372  self->device = roar_mm_strdup(device); 
    373373 
    374374 if ( driver_oss_init_vio(inst, self) == -1 ) { 
     
    419419 
    420420 if ( _get(vio,device) != NULL ) 
    421   free(_get(vio,device)); 
    422  
    423  free(vio->inst); 
     421  roar_mm_free(_get(vio,device)); 
     422 
     423 roar_mm_free(vio->inst); 
    424424 return 0; 
    425425} 
  • roard/driver_pwmled.c

    r4708 r4957  
    3030int driver_pwmled_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) { 
    3131 struct roar_vio_defaults def; 
    32  struct driver_pwmled * self = malloc(sizeof(struct driver_pwmled)); 
     32 struct driver_pwmled * self = roar_mm_malloc(sizeof(struct driver_pwmled)); 
    3333 
    3434 if ( self == NULL ) 
     
    4040 
    4141  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 ) { 
    42    free(self); 
     42   roar_mm_free(self); 
    4343   return -1; 
    4444  } 
    4545 
    4646  if ( roar_vio_open_dstr(&(self->vio), device, &def, 1) == -1 ) { 
    47    free(self); 
     47   roar_mm_free(self); 
    4848   return -1; 
    4949  } 
     
    5555   return -1; 
    5656*/ 
    57   free(self); 
     57  roar_mm_free(self); 
    5858  return -1; 
    5959 } 
     
    7878 
    7979 if ( roar_light_pwm_new(&(self->state), 16) == -1 ) { 
    80   free(self); 
     80  roar_mm_free(self); 
    8181  return -1; 
    8282 } 
     
    9292 
    9393 if ( vio->inst != NULL ) 
    94   free(vio->inst); 
     94  roar_mm_free(vio->inst); 
    9595 
    9696 return ret; 
  • roard/driver_sndio.c

    r4708 r4957  
    5252 struct driver_sndio * self = NULL; 
    5353 
    54  if ( (self = malloc(sizeof(struct driver_sndio))) == NULL ) { 
    55   ROAR_ERR("driver_sndio_open(*): Can not malloc() instance data: %s", strerror(errno)); 
     54 if ( (self = roar_mm_malloc(sizeof(struct driver_sndio))) == NULL ) { 
     55  ROAR_ERR("driver_sndio_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno)); 
    5656  return -1; 
    5757 } 
     
    8585 
    8686 if ( device != NULL ) 
    87   self->device = strdup(device); 
     87  self->device = roar_mm_strdup(device); 
    8888 
    8989 if ( driver_sndio_init_vio(inst, self) == -1 ) { 
     
    113113 
    114114 if ( self->device != NULL ) 
    115   free(self->device); 
    116  
    117  free(self); 
     115  roar_mm_free(self->device); 
     116 
     117 roar_mm_free(self); 
    118118 
    119119 return 0; 
  • roard/driver_wmm.c

    r4708 r4957  
    3535  MMRESULT mmres; 
    3636 
    37   self->bigbuffer = malloc(bytes); 
     37  self->bigbuffer = roar_mm_malloc(bytes); 
    3838  if (self->bigbuffer != NULL) { 
    3939    int i; 
     
    6060                               &self->wh[i].wh,sizeof(WAVEHDR)); 
    6161      } 
    62       free(self->bigbuffer); 
     62      roar_mm_free(self->bigbuffer); 
    6363      self->wh        = 0; 
    6464      self->spl       = 0; 
     
    182182 MMRESULT mmres; 
    183183 
    184  if ( (self = malloc(sizeof(struct driver_wmm))) == NULL ) 
     184 if ( (self = roar_mm_malloc(sizeof(struct driver_wmm))) == NULL ) 
    185185  return -1; 
    186186 
     
    252252 } 
    253253 
    254  free(self); 
     254 roar_mm_free(self); 
    255255 
    256256 ROAR_DBG("driver_wmm_close_vio(*) = 0"); 
  • roard/light.c

    r4708 r4957  
    3737  return -1; 
    3838 
    39  if ( (g_light_state.state = malloc(channels)) == NULL ) { 
    40   return -1; 
    41  } 
    42  
    43  if ( (g_light_state.changes = malloc(channels)) == NULL ) { 
    44   free(g_light_state.state); 
     39 if ( (g_light_state.state = roar_mm_malloc(channels)) == NULL ) { 
     40  return -1; 
     41 } 
     42 
     43 if ( (g_light_state.changes = roar_mm_malloc(channels)) == NULL ) { 
     44  roar_mm_free(g_light_state.state); 
    4545  return -1; 
    4646 } 
     
    4949 
    5050 if ( (g_light_mixer.stream = add_mixer(ROAR_SUBSYS_LIGHT, _MIXER_NAME("Light Control"), &ss)) == -1 ) { 
    51   free(g_light_state.state); 
     51  roar_mm_free(g_light_state.state); 
    5252  return -1; 
    5353 } 
     
    7070int light_free  (void) { 
    7171 if ( g_light_state.state != NULL ) { 
    72   free(g_light_state.state); 
     72  roar_mm_free(g_light_state.state); 
    7373 } 
    7474 
    7575 if ( g_light_state.changes != NULL ) { 
    76   free(g_light_state.changes); 
     76  roar_mm_free(g_light_state.changes); 
    7777 } 
    7878 
  • roard/sample.c

    r4708 r4957  
    4747 
    4848int samples_new       (void) { 
    49  struct roar_sample * c = malloc(sizeof(struct roar_sample)); 
     49 struct roar_sample * c = roar_mm_malloc(sizeof(struct roar_sample)); 
    5050 int i; 
    5151 
     
    6363 } 
    6464 
    65  free(c); 
     65 roar_mm_free(c); 
    6666 
    6767 return -1; 
  • roard/streams.c

    r4934 r4957  
    372372 
    373373 if ( s->output != NULL ) 
    374   free(s->output); 
     374  roar_mm_free(s->output); 
    375375 
    376376/* 
     
    386386 
    387387 if ( s->name != NULL ) 
    388   free(s->name); 
     388  roar_mm_free(s->name); 
    389389 
    390390 roar_mm_free(s); 
     
    13361336 _CHECK_SID(id); 
    13371337 
    1338  if ( (str = strdup(name)) == NULL ) 
     1338 if ( (str = roar_mm_strdup(name)) == NULL ) 
    13391339  return -1; 
    13401340 
    13411341 if ( g_streams[id]->name != NULL ) 
    1342   free(g_streams[id]->name); 
     1342  roar_mm_free(g_streams[id]->name); 
    13431343 
    13441344 g_streams[id]->name = str; 
     
    17221722 } 
    17231723 
    1724  if ( (g_streams[id]->output = malloc(size)) == NULL ) { 
     1724 if ( (g_streams[id]->output = roar_mm_malloc(size)) == NULL ) { 
    17251725  ROAR_ERR("streams_get_outputbuffer(*): Can not alloc: %s", strerror(errno)); 
    17261726  return -1; 
Note: See TracChangeset for help on using the changeset viewer.