effect_position.c
changeset 561 87bdb4c81c0b
parent 518 8bc9b5fd2aae
child 601 05123263dab3
child 887 e49459791ae8
equal deleted inserted replaced
560:0fc8dffb86c5 561:87bdb4c81c0b
    83 
    83 
    84 void _Eff_PositionDeinit(void)
    84 void _Eff_PositionDeinit(void)
    85 {
    85 {
    86     int i;
    86     int i;
    87     for (i = 0; i < position_channels; i++) {
    87     for (i = 0; i < position_channels; i++) {
    88         free(pos_args_array[i]);
    88         SDL_free(pos_args_array[i]);
    89     }
    89     }
    90 
    90 
    91     position_channels = 0;
    91     position_channels = 0;
    92 
    92 
    93     free(pos_args_global);
    93     SDL_free(pos_args_global);
    94     pos_args_global = NULL;
    94     pos_args_global = NULL;
    95     free(pos_args_array);
    95     SDL_free(pos_args_array);
    96     pos_args_array = NULL;
    96     pos_args_array = NULL;
    97 }
    97 }
    98 
    98 
    99 
    99 
   100 /* This just frees up the callback-specific data. */
   100 /* This just frees up the callback-specific data. */
   101 static void _Eff_PositionDone(int channel, void *udata)
   101 static void _Eff_PositionDone(int channel, void *udata)
   102 {
   102 {
   103     if (channel < 0) {
   103     if (channel < 0) {
   104         if (pos_args_global != NULL) {
   104         if (pos_args_global != NULL) {
   105             free(pos_args_global);
   105             SDL_free(pos_args_global);
   106             pos_args_global = NULL;
   106             pos_args_global = NULL;
   107         }
   107         }
   108     }
   108     }
   109 
   109 
   110     else if (pos_args_array[channel] != NULL) {
   110     else if (pos_args_array[channel] != NULL) {
   111         free(pos_args_array[channel]);
   111         SDL_free(pos_args_array[channel]);
   112         pos_args_array[channel] = NULL;
   112         pos_args_array[channel] = NULL;
   113     }
   113     }
   114 }
   114 }
   115 
   115 
   116 
   116 
  1147     void *rc;
  1147     void *rc;
  1148     int i;
  1148     int i;
  1149 
  1149 
  1150     if (channel < 0) {
  1150     if (channel < 0) {
  1151         if (pos_args_global == NULL) {
  1151         if (pos_args_global == NULL) {
  1152             pos_args_global = malloc(sizeof (position_args));
  1152             pos_args_global = SDL_malloc(sizeof (position_args));
  1153             if (pos_args_global == NULL) {
  1153             if (pos_args_global == NULL) {
  1154                 Mix_SetError("Out of memory");
  1154                 Mix_SetError("Out of memory");
  1155                 return(NULL);
  1155                 return(NULL);
  1156             }
  1156             }
  1157             init_position_args(pos_args_global);
  1157             init_position_args(pos_args_global);
  1159 
  1159 
  1160         return(pos_args_global);
  1160         return(pos_args_global);
  1161     }
  1161     }
  1162 
  1162 
  1163     if (channel >= position_channels) {
  1163     if (channel >= position_channels) {
  1164         rc = realloc(pos_args_array, (channel + 1) * sizeof (position_args *));
  1164         rc = SDL_realloc(pos_args_array, (channel + 1) * sizeof (position_args *));
  1165         if (rc == NULL) {
  1165         if (rc == NULL) {
  1166             Mix_SetError("Out of memory");
  1166             Mix_SetError("Out of memory");
  1167             return(NULL);
  1167             return(NULL);
  1168         }
  1168         }
  1169         pos_args_array = (position_args **) rc;
  1169         pos_args_array = (position_args **) rc;
  1172         }
  1172         }
  1173         position_channels = channel + 1;
  1173         position_channels = channel + 1;
  1174     }
  1174     }
  1175 
  1175 
  1176     if (pos_args_array[channel] == NULL) {
  1176     if (pos_args_array[channel] == NULL) {
  1177         pos_args_array[channel] = (position_args *)malloc(sizeof(position_args));
  1177         pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
  1178         if (pos_args_array[channel] == NULL) {
  1178         if (pos_args_array[channel] == NULL) {
  1179             Mix_SetError("Out of memory");
  1179             Mix_SetError("Out of memory");
  1180             return(NULL);
  1180             return(NULL);
  1181         }
  1181         }
  1182         init_position_args(pos_args_array[channel]);
  1182         init_position_args(pos_args_array[channel]);