Changeset 4975:1b8be0a0ba5f in roaraudio for libroar


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.

Location:
libroar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.