Changeset 4975:1b8be0a0ba5f in roaraudio


Ignore:
Timestamp:
05/16/11 15:16:33 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

removed more usages of system's malloc()/free() calles.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/vio_stack.h

    r4708 r4975  
    4444 int next; 
    4545 
     46 void (*free)(void*); 
     47 
    4648 struct roar_vio_calls * cur; 
    4749 
     
    5052 
    5153int     roar_vio_open_stack    (struct roar_vio_calls * calls); 
     54int     roar_vio_open_stack2   (struct roar_vio_calls * calls, void (*func)(void*)); 
    5255int     roar_vio_stack_add     (struct roar_vio_calls * calls, struct roar_vio_calls * vio); 
    5356 
  • libroar.ckport

    r4970 r4975  
    268268 
    269269# VIO Stack: 
    270 roar_vio_open_stack             ok 
     270roar_vio_open_stack             legacy  Use roar_vio_open_stack2 
     271roar_vio_open_stack2            ok 
    271272roar_vio_stack_add              ok 
    272273 
     
    610611roar_mm_munlock                 ok 
    611612 
     613roar_mm_free_retvoid            likely  Use roar_mm_free when possible (No error checking by caller) 
     614 
    612615_ROAR_MLOCK                     legacy  Use roar_mm_mlock 
    613616 
  • libroar/vio_cmd.c

    r4956 r4975  
    6262 
    6363 if ( reader != NULL ) 
    64   state->reader.cmd = strdup(reader); 
     64  state->reader.cmd = roar_mm_strdup(reader); 
    6565 
    6666 state->writer.pid = -1; 
     
    6969 
    7070 if ( writer != NULL ) 
    71   state->writer.cmd = strdup(writer); 
     71  state->writer.cmd = roar_mm_strdup(writer); 
    7272 
    7373 // init state 
     
    125125 
    126126 if ( state->reader.cmd != NULL ) 
    127   free(state->reader.cmd); 
     127  roar_mm_free(state->reader.cmd); 
    128128 
    129129 if ( state->writer.cmd != NULL ) 
    130   free(state->writer.cmd); 
     130  roar_mm_free(state->writer.cmd); 
    131131 
    132132 roar_vio_close(state->next); 
     
    241241 state->child.out = -1; 
    242242 
    243  state->child.cmd = strdup(command); 
     243 state->child.cmd = roar_mm_strdup(command); 
    244244 
    245245 // init state 
     
    281281 
    282282 if ( state->child.cmd != NULL ) 
    283   free(state->child.cmd); 
     283  roar_mm_free(state->child.cmd); 
    284284 
    285285 roar_mm_free(state); 
  • libroar/vio_dstr.c

    r4964 r4975  
    770770  return -1; 
    771771 
    772  if ( roar_vio_open_stack(calls) == -1 ) 
     772 if ( roar_vio_open_stack2(calls, NULL) == -1 ) 
    773773  return -1; 
    774774 
     
    776776 
    777777 if ( (def = chain->def) != NULL ) { 
    778   if ( (tc = malloc(sizeof(struct roar_vio_calls))) == NULL ) { 
     778  if ( (tc = roar_mm_malloc(sizeof(struct roar_vio_calls))) == NULL ) { 
    779779   _ret(-1); 
    780780  } 
    781781 
    782782  if ( roar_vio_clear_calls(tc) == -1 ) { 
    783    free(tc); 
     783   roar_mm_free(tc); 
    784784   _ret(-1); 
    785785  } 
     
    809809 
    810810  if ( c->need_vio ) { 
    811    if ( (tc = malloc(sizeof(struct roar_vio_calls))) == NULL ) { 
     811   if ( (tc = roar_mm_malloc(sizeof(struct roar_vio_calls))) == NULL ) { 
    812812    _ret(-1); 
    813813   } 
    814814 
    815815   if ( roar_vio_clear_calls(tc) == -1 ) { 
    816     free(tc); 
     816    roar_mm_free(tc); 
    817817    _ret(-1); 
    818818   } 
  • libroar/vio_stack.c

    r4708 r4975  
    3737 
    3838int     roar_vio_open_stack    (struct roar_vio_calls * calls) { 
     39 return roar_vio_open_stack2(calls, free); 
     40} 
     41 
     42int     roar_vio_open_stack2   (struct roar_vio_calls * calls, void (*func)(void*)) { 
    3943 struct roar_vio_stack * self; 
    4044 
    41  if ( calls == NULL ) 
    42   return -1; 
     45 if ( calls == NULL ) { 
     46  roar_err_set(ROAR_ERROR_FAULT); 
     47  return -1; 
     48 } 
     49 
     50 if ( func == NULL ) 
     51  func = roar_mm_free_retvoid; 
    4352 
    4453 if ( (self = roar_mm_malloc(sizeof(struct roar_vio_stack))) == NULL ) 
     
    4756 memset(self,  0, sizeof(struct roar_vio_stack)); 
    4857 memset(calls, 0, sizeof(struct roar_vio_calls)); 
     58 
     59 self->free      = func; 
    4960 
    5061 calls->inst     = self; 
     
    6374 struct roar_vio_stack * self; 
    6475 
    65  if ( calls == NULL || vio == NULL ) 
    66   return -1; 
    67  
    68  if ( (self = calls->inst) == NULL ) 
    69   return -1; 
     76 if ( calls == NULL || vio == NULL ) { 
     77  roar_err_set(ROAR_ERROR_FAULT); 
     78  return -1; 
     79 } 
     80 
     81 if ( (self = calls->inst) == NULL ) { 
     82  roar_err_set(ROAR_ERROR_FAULT); 
     83  return -1; 
     84 } 
    7085 
    7186 if ( self->next == ROAR_VIO_STACK_MAX ) 
     
    8196 int i; 
    8297 
    83  if ( vio == NULL ) 
    84   return -1; 
     98 if ( vio == NULL ) { 
     99  roar_err_set(ROAR_ERROR_FAULT); 
     100  return -1; 
     101 } 
    85102 
    86103 if ( (self = vio->inst) == NULL ) 
     
    92109 
    93110  for (i = 0; i < self->next; i++) 
    94    free(self->calls[i]); 
     111   self->free(self->calls[i]); 
    95112 } 
    96113 
  • libroaresd/esdctl.c

    r4708 r4975  
    6969 
    7070/* print server into to stdout */ 
    71 void esd_print_server_info( esd_server_info_t *server_info ) { 
     71void esd_print_server_info(esd_server_info_t *server_info ) { 
    7272 char buf[80] = ""; 
    7373 
     
    142142 struct roar_message    m; 
    143143 
    144  r = malloc(sizeof(esd_server_info_t)); 
     144 r = roar_mm_malloc(sizeof(esd_server_info_t)); 
    145145 
    146146 if ( r == NULL ) 
     
    157157 
    158158 if ( roar_req(&con, &m, NULL) == -1 ) { 
    159   free(r); 
     159  roar_mm_free(r); 
    160160  return NULL; 
    161161 } 
    162162 
    163163 if ( m.cmd != ROAR_CMD_OK ) { 
    164   free(r); 
     164  roar_mm_free(r); 
    165165  return NULL; 
    166166 } 
    167167 
    168168 if ( roar_stream_m2s(&s, &m) == -1 ) { 
    169   free(r); 
     169  roar_mm_free(r); 
    170170  return NULL; 
    171171 } 
     
    188188/* release all memory allocated for the server properties structure */ 
    189189void esd_free_server_info( esd_server_info_t *server_info ) { 
    190  if (server_info) 
    191   free(server_info); 
     190 if (server_info != NULL) 
     191  roar_mm_free(server_info); 
    192192} 
    193193 
     
    208208 roar_connect_fh(con, esd); 
    209209 
    210  r = malloc(sizeof(esd_info_t)); 
     210 r = roar_mm_malloc(sizeof(esd_info_t)); 
    211211 
    212212 if ( r == NULL ) 
     
    234234   } 
    235235 
    236    if ( (new_player = malloc(sizeof(esd_player_info_t))) == NULL ) { 
     236   if ( (new_player = roar_mm_malloc(sizeof(esd_player_info_t))) == NULL ) { 
    237237    ROAR_ERR("esd_get_all_info(*): can not alloc memory for new player! BAD"); 
    238238    continue; 
     
    320320 player = info->player_list; 
    321321 
    322  while (player) { 
     322 while (player != NULL) { 
    323323  oplayer = player; 
    324324  player  = player->next; 
    325325 
    326   free(oplayer); 
     326  roar_mm_free(oplayer); 
    327327 } 
    328328 
     
    333333  sample  = sample->next; 
    334334 
    335   free(osample); 
    336  } 
    337  
    338   free(info); 
     335  roar_mm_free(osample); 
     336 } 
     337 
     338  roar_mm_free(info); 
    339339 } 
    340340} 
  • roard/driver.c

    r4955 r4975  
    302302  return -1; 
    303303 } else { 
    304   driver = strdup(device); 
     304  driver = roar_mm_strdup(device); 
    305305 
    306306  if ( (delm = strstr(driver, "#")) == NULL ) { 
     
    317317 
    318318 if ( driver != NULL ) 
    319   free(driver); 
     319  roar_mm_free(driver); 
    320320 
    321321 return ret; 
  • roard/driver_sndio.c

    r4957 r4975  
    4343} 
    4444 
    45 #define er() if ( self->shandle ) sio_close(self->shandle); \ 
    46              if ( self->mhandle ) mio_close(self->mhandle); \ 
    47              if ( self->device  ) free(self->device);      \ 
    48              free(self);                                    \ 
     45#define er() if ( self->shandle ) sio_close(self->shandle);   \ 
     46             if ( self->mhandle ) mio_close(self->mhandle);   \ 
     47             if ( self->device  ) roar_mm_free(self->device); \ 
     48             roar_mm_free(self);                              \ 
    4949             return -1 
    5050 
  • roard/roard.c

    r4967 r4975  
    828828   if ( *addr == '/' ) { 
    829829    if ( (env_roar_proxy_backup = getenv("ROAR_PROXY")) != NULL ) { 
    830      env_roar_proxy_backup = strdup(env_roar_proxy_backup); 
     830     env_roar_proxy_backup = roar_mm_strdup(env_roar_proxy_backup); 
    831831     unsetenv("ROAR_PROXY"); 
    832832    } 
     
    844844    if ( env_roar_proxy_backup != NULL ) { 
    845845     setenv("ROAR_PROXY", env_roar_proxy_backup, 0); 
    846      free(env_roar_proxy_backup); 
     846     roar_mm_free(env_roar_proxy_backup); 
    847847    } 
    848848#else 
  • roard/sample.c

    r4957 r4975  
    7777  roar_buffer_free(c->data); 
    7878 
    79  free(c); 
     79 roar_mm_free(c); 
    8080 
    8181 g_samples[id] = NULL; 
Note: See TracChangeset for help on using the changeset viewer.