Exemplo n.º 1
0
void free_minteg(minteg *mit)
{
  int i;
  for ( i = 0 ; i < mit->integ_array_size ; i++ )
  {
    if ( mit->integ_array[i] != NULL )
      free_integ(mit->integ_array[i]);
  }

  AM_FREE_ARRAY(mit->integ_array,integ_ptr,mit->integ_array_size);
  AM_FREE(mit,minteg);
}
Exemplo n.º 2
0
void free_string_array(string_array *sar)
{
  int i;
  sar -> string_array_code = 7777;

  for ( i = 0 ; i < sar->size ; i++ )
    if ( sar->sarr[i] != NULL )
      am_free_string(sar->sarr[i]);

  AM_FREE_ARRAY(sar->sarr,char_ptr,sar->sarr_size);
  AM_FREE(sar,string_array);

  String_Arrays_freed += 1;
}
Exemplo n.º 3
0
/* only for people who really want to save time allocating memory.
   after calling this, you should forget about the memory in string without
   freeing it.
 */
void add_to_string_array_no_copy(string_array *sa, char *string)
{
  if ( sa -> size == sa -> sarr_size )
  {
    int new_sarr_size = 2 + 2 * sa->sarr_size;
    char **new_sarr = AM_MALLOC_ARRAY(char_ptr,new_sarr_size);
    int i;

    for ( i = 0 ; i < sa->size ; i++ ) new_sarr[i] = sa->sarr[i];

    AM_FREE_ARRAY(sa->sarr,char_ptr,sa->sarr_size);
    sa -> sarr_size = new_sarr_size;
    sa -> sarr = new_sarr;
  }

  sa -> size += 1;
  sa -> sarr[sa->size-1] = string;
}