예제 #1
0
void deinitialise_group_task_array (void)
{
	int
		loop;

	ASSERT (group_task_array);

	for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_GROUPS; loop ++)
	{
		free_mem (group_task_array [loop]);
	}

	free_mem (group_task_array);

	group_task_array = NULL;
}
예제 #2
0
void leave() {
	if (is_inroom()) {
		if (allocate_mem(ROOM, &room_data)) {
			room_data->type = ROOM;
			room_data->operation_type = LEAVE_ROOM;
			strcpy(room_data->user_name, username);
			strcpy(room_data->room_name, roomname);
			if (send_message(room_data->type, room_data) != FAIL && wait_until_received(RESPONSE) != FAIL) {
				inroom = 0;
           		if (response_data.response_type == LEAVE_ROOM_SUCCESS) {
           			writestr("Successfully left room");
				}
				else {
					writestr("Some error occurred.");
				}
			}
			free_mem(room_data);
		}
		else {
			writestr("Couldn't allocate room_data structure.");
		}
	}
	else {
		writestr("To perform it, you have to be in room.");
	}
}
예제 #3
0
파일: protocol.c 프로젝트: djjsindy/dawn
static void get_queue_stat(connection_t *conn){
  list_head_t *head=visit_hash(stat->queue_data_hash);
  while(!list_is_empty(head)){
    hash_entry_t *entry=(hash_entry_t *)list_entry(head->next,hash_entry_t,list);
    queue_stat_t *qs=(queue_stat_t *)entry->data;
    item_t *i=init_item();
    i->data=alloc_mem(pool,STAT_LINE_BUFFER_SIZE);
    i->end=1;
    snprintf(i->data,STAT_LINE_BUFFER_SIZE,"queue_name:%s,size:%ld,bytes:%ld\n",qs->name,qs->size,qs->bytes);
    i->c_size=strlen(i->data);
    push(conn->wc->w_queue,i);
    free_mem(entry);
    list_del_data(head,head->next->next); 
  }
  free_mem(head);
}
예제 #4
0
파일: protocol.c 프로젝트: djjsindy/dawn
static item_t* fill_get_response_header(char *key ,intptr_t bytes){
  char *s=(char *)alloc_mem(pool,20);
  sprintf(s,"%ld",bytes);
  intptr_t first_length=strlen(first_get_response);
  intptr_t key_length=strlen(key);
  intptr_t middle_length=strlen(middle);
  intptr_t s_length=strlen(s);
  intptr_t command_end_length=strlen(command_end);
  intptr_t length=first_length+key_length+middle_length+s_length+command_end_length;
  char *c=(char *)alloc_mem(pool,length);
  memset(c,0,length);
  intptr_t index=0;
  memcpy(c,first_get_response,first_length);
  index+=first_length;
  memcpy(c+index,key,key_length);
  index+=key_length;
  memcpy(c+index,middle,middle_length);
  index+=middle_length;
  memcpy(c+index,s,s_length);
  index+=s_length;
  memcpy(c+index,command_end,command_end_length);
  index+=command_end_length;
  
  free_mem(s);
  item_t *i=init_item();
  i->data=c;
  i->c_size=length;
  return i;
}
예제 #5
0
STATS::~STATS (                  //destructor
) {
  if (buckets != NULL) {
    free_mem(buckets);
    buckets = NULL;
  }
}
int main(int argc, char* argv[]){
    if(argc == 5){
        request.siz = atoi(argv[3]);
        request.beg = atoi(argv[2]);
        if(argv[4][0] == 'b'){
            isWorst = false;
        }else{
            isWorst = true;
        }
    }else if(argc == 4){
        request.siz = atoi(argv[2]);
        request.beg = -1;
        printf("!\n");
        if(argv[3][0] == 'b'){
            isWorst = false;
        }else{
            isWorst = true;
        }
    }else{
        printf("EX0: match.exe free 12 20 b(release 20 bytes, begin at 12, using best-matching).\nEX1: match.exe malloc 28 w(allocate 28 bytes, using worst-matching)\n");
        exit(0);
    }
    
    int begin, size;
    Node* p = &head;
    FILE* in;
    if(!(in = fopen("stats.txt", "r"))){
        printf("Fail to acquire memory States!\n");
    }
    
    while(~fscanf(in, "%d %d", &begin, &size)){
        printf("%d %d\n", begin, size);
        Node* newNode = new Node();
        p->nxt = newNode;
        p->beg = begin;
        p->siz = size;
        newNode->beg = -1;
        newNode->siz = 0;
        newNode->nxt = NULL;
        p = p->nxt;
        blocks ++;
    }
    fclose(in);
    
    printf("We get:\n");
    show_list();
    
    if(request.beg != -1){
        free_mem();
    }else if(isWorst){
        malloc_worst();
    }else{
        malloc_best();
    }
        
    printf("Current Mem-states:\n");
    show_list();
    write_back();
    return 0;
}
예제 #7
0
파일: recycle.c 프로젝트: verias/SRMud
void free_pcdata(PC_DATA *pcdata)
{
    int alias;
   GRANT_DATA *gran,*gran_next;

    if (!IS_VALID(pcdata))
	return;

    free_string(pcdata->pwd);
    free_string(pcdata->bamfin);
    free_string(pcdata->bamfout);
    free_string(pcdata->title);
    free_buf(pcdata->buffer);

     for (gran = pcdata->granted; gran != NULL; gran = gran_next)
    {
        gran_next = gran->next;
        free_string(gran->name);
        free_mem(gran,sizeof(*gran));
    }

    for (alias = 0; alias < MAX_ALIAS; alias++)
    {
	free_string(pcdata->alias[alias]);
	free_string(pcdata->alias_sub[alias]);
    }
    INVALIDATE(pcdata);
    pcdata->next = pcdata_free;
    pcdata_free = pcdata;

    return;
}
예제 #8
0
void hd_scan_modem(hd_data_t *hd_data)
{
  ser_device_t *sm, *sm_next;

  if(!hd_probe_feature(hd_data, pr_modem)) return;

  hd_data->module = mod_modem;

  /* some clean-up */
  remove_hd_entries(hd_data);
  hd_data->ser_modem = NULL;

  PROGRESS(1, 0, "serial");

  hd_fork(hd_data, 15, 120);

  if(hd_data->flags.forked) {
    get_serial_modem(hd_data);
    hd_move_to_shm(hd_data);
    if((hd_data->debug & HD_DEB_MODEM)) dump_ser_modem_data(hd_data);
  }
  else {
    /* take data from shm */
    hd_data->ser_modem = ((hd_data_t *) (hd_data->shm.data))->ser_modem;
    if((hd_data->debug & HD_DEB_MODEM)) dump_ser_modem_data(hd_data);
  }

  hd_fork_done(hd_data);

  add_serial_modem(hd_data);

  hd_shm_clean(hd_data);

  for(sm = hd_data->ser_modem; sm; sm = sm_next) {
    sm_next = sm->next;

    free_str_list(sm->at_resp);

    free_mem(sm->dev_name);
    free_mem(sm->serial);
    free_mem(sm->class_name);
    free_mem(sm->dev_id);
    free_mem(sm->user_name);
    free_mem(sm->vend);
    free_mem(sm->init_string1);
    free_mem(sm->init_string2);

    free_mem(sm);
  }
  hd_data->ser_modem = NULL;

}
예제 #9
0
PROTECTED int
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
		    unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen)
{
  int mib[4], error, ret;
  size_t len, len1;
  char *buf, *bp, *eb;
  struct kinfo_vmentry *kv;

  len = 0;
  mib[0] = CTL_KERN;
  mib[1] = KERN_PROC;
  mib[2] = KERN_PROC_VMMAP;
  mib[3] = pid;

  error = sysctl(mib, 4, NULL, &len, NULL, 0);
  if (error)
    return (-1);
  len1 = len * 4 / 3;
  buf = get_mem(len1);
  if (buf == NULL)
    return (-1);
  len = len1;
  error = sysctl(mib, 4, buf, &len, NULL, 0);
  if (error) {
    free_mem(buf, len1);
    return (-1);
  }
  ret = -1;
  for (bp = buf, eb = buf + len; bp < eb; bp += kv->kve_structsize) {
     kv = (struct kinfo_vmentry *)(uintptr_t)bp;
     if (ip < kv->kve_start || ip >= kv->kve_end)
       continue;
     if (kv->kve_type != KVME_TYPE_VNODE)
       break;
     *segbase = kv->kve_start;
     *mapoff = kv->kve_offset;
     if (path)
       {
         strncpy(path, kv->kve_path, pathlen);
       }
     ret = elf_map_image(ei, kv->kve_path);
     break;
  }
  free_mem(buf, len1);
  return (ret);
}
예제 #10
0
void cgi_process_var (U8 *qs) {
  /* This function is called by HTTP server to process the Querry_String   */
  /* for the CGI Form GET method. It is called on SUBMIT from the browser. */
  /*.The Querry_String.is SPACE terminated.                                */
  U8 *var;
  int s[4];
	
  var = (U8 *)alloc_mem (40);
  do {
    /* Loop through all the parameters. */
    qs = http_get_var (qs, var, 40);
    /* Check the returned string, 'qs' now points to the next. */
    if (var[0] != 0) {
      /* Returned string is non 0-length. */
      if (str_scomp (var, (U8 *)"ip=") == __TRUE) {
        /* My IP address parameter. */
        sscanf ((const char *)&var[3], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
        LocM.IpAdr[0]   = s[0];
        LocM.IpAdr[1]   = s[1];
        LocM.IpAdr[2]   = s[2];
        LocM.IpAdr[3]   = s[3];
      }
      else if (str_scomp (var, (U8 *)"msk=") == __TRUE) {
        /* Net mask parameter. */
        sscanf ((const char *)&var[4], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
        LocM.NetMask[0] = s[0];
        LocM.NetMask[1] = s[1];
        LocM.NetMask[2] = s[2];
        LocM.NetMask[3] = s[3];
				
      }
      else if (str_scomp (var, (U8 *)"gw=") == __TRUE) {
        /* Default gateway parameter. */
        sscanf ((const char *)&var[3], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
        LocM.DefGW[0]   = s[0];
        LocM.DefGW[1]   = s[1];
        LocM.DefGW[2]   = s[2];
        LocM.DefGW[3]   = s[3];
      }
      else if (str_scomp (var, (U8 *)"pdns=") == __TRUE) {
        /* Default gateway parameter. */
        sscanf ((const char *)&var[5], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
        LocM.PriDNS[0]  = s[0];
        LocM.PriDNS[1]  = s[1];
        LocM.PriDNS[2]  = s[2];
        LocM.PriDNS[3]  = s[3];
      }
      else if (str_scomp (var, (U8 *)"sdns=") == __TRUE) {
        /* Default gateway parameter. */
        sscanf ((const char *)&var[5], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
        LocM.SecDNS[0]  = s[0];
        LocM.SecDNS[1]  = s[1];
        LocM.SecDNS[2]  = s[2];
        LocM.SecDNS[3]  = s[3];
      }
    }
  }while (qs);
  free_mem ((OS_FRAME *)var);
}
예제 #11
0
bool_t free_jumptable(jumptable_t *jt) {
  if( jt ) {
    jt->num = 0;
    free_mem(&jt->hash, &jt->maxnum);
    return TRUE;
  }
  return FALSE;
}
예제 #12
0
bool_t free_symbols(symbols_t *sb) {
  if( sb ) {
    free_mem(&sb->bigs, &sb->bigmax);
    free_jumptable(&sb->jt);
    return TRUE;
  }
  return FALSE;
}
예제 #13
0
static int		ending_file(char **line, char **templine, char **buf)
{
	*line = ft_strdup(*templine);
	free_mem(buf, templine);
	if (line[0] == '\0')
		return (0);
	return (1);
}
예제 #14
0
/* PUBLIC */
void free_term(Term p)
{
  if (VARIABLE(p))
    return;  /* variables are never freed, because they are shared */
  Arg_mem -= p->arity;
  free_mem(p, PTRS_TERM + p->arity);
  Term_frees++;
}  /* free_term */
예제 #15
0
/* PUBLIC */
void free_context(Context p)
{
  if (Multipliers[p->multiplier] == FALSE)
    fatal_error("free_context, bad multiplier");
  Multipliers[p->multiplier] = FALSE;
  free_mem(p, PTRS_CONTEXT);
  Context_frees++;
}  /* free_context */
예제 #16
0
파일: y86sim.c 프로젝트: tjgykhulj/ICS_Lab
int main(int argc, char *argv[])
{
    FILE *binfile;
    int max_steps = MAX_STEP;
    y86sim_t *sim;
    mem_t *saver, *savem;
    int step = 0;
    stat_t e = STAT_AOK;

    if (argc < 2 || argc > 3)
        usage(argv[0]);

    /* set max steps */
    if (argc > 2)
        max_steps = atoi(argv[2]);

    /* load binary file to memory */
    if (strcmp(argv[1]+(strlen(argv[1])-4), ".bin"))
        usage(argv[0]); /* only support *.bin file */
    
    binfile = fopen(argv[1], "rb");
    if (!binfile) {
        err_print("Can't open binary file '%s'", argv[1]);
        exit(1);
    }

    sim = new_y86sim(MEM_SIZE);
    if (load_binfile(sim->m, binfile) < 0) {
        err_print("Failed to load binary file '%s'", argv[1]);
        free_y86sim(sim);
        exit(1);
    }
    fclose(binfile);

    /* save initial register and memory stat */
    saver = dup_reg(sim->r);
    savem = dup_mem(sim->m);

    /* execute binary code step-by-step */
    for (step = 0; step < max_steps && e == STAT_AOK; step++)
        e = nexti(sim);

    /* print final stat of y86sim */
    printf("Stopped in %d steps at PC = 0x%x.  Status '%s', CC %s\n",
            step, sim->pc, stat_name(e), cc_name(sim->cc));

    printf("Changes to registers:\n");
    diff_reg(saver, sim->r, stdout);

    printf("\nChanges to memory:\n");
    diff_mem(savem, sim->m, stdout);

    free_y86sim(sim);
    free_reg(saver);
    free_mem(savem);

    return 0;
}
예제 #17
0
sexpr sx_join (sexpr a, sexpr b, sexpr c)
{
    unsigned int j = 0, k = 0;
    const char *s;

    if (integerp (a))
    {
        a = sx_to_string (a);
    }
    if (integerp (b))
    {
        b = sx_to_string (b);
    }
    if (integerp (c))
    {
        c = sx_to_string (c);
    }

    if (stringp (a) || symbolp(a))
    {
        s = stringp (a) ? sx_string (a) : sx_symbol(a);
        for (j = 0; s[j]; j++) k++;
    }
    else
    {
        return sx_nil;
    }
    if (stringp (b) || symbolp(b))
    {
        s = stringp (b) ? sx_string (b) : sx_symbol(b);
        for (j = 0; s[j]; j++) k++;
    }
    if (stringp (c) || symbolp(c))
    {
        s = stringp (c) ? sx_string (c) : sx_symbol(c);
        for (j = 0; s[j]; j++) k++;
    }

    k++;

    if (k < STACK_BUFFER_SIZE)
    {
        char buf[STACK_BUFFER_SIZE];

        return sx_join_work (a, b, c, buf);
    }
    else
    {
        char *g = get_mem (k);
        sexpr rv;

        rv = sx_join_work (a, b, c, g);

        free_mem (k, g);

        return rv;
    }
}
예제 #18
0
파일: timer.c 프로젝트: RAHUL04/RIPv1
/* Function to stop timer
   Parameters:
   1) handle  : Address of timer structure returned by start_timer 
*/
void stop_timer(timer_info_ptr_t handle)
{
  /* Header under which this timer exists */
  timer_header_ptr_t header = handle->up;
  
  /* Obtain the lock to perform timer operations */
  pthread_mutex_lock(&timer_ds.currenttime_mutex);


  /* Update the link list of the timers */
  if(handle->next!=NULL)
    handle->next->prev = handle->prev;
  if(handle->prev!=NULL)
    handle->prev->next = handle->next;

  /* If the timer to be stopped is the first timer under the header */
  if(header->down == handle)
    header->down = handle->next;
  
  /* Reduce the count of timers in the header */
  header->number_of_timers --;

  /* If the timer is the only timer under this header, free this header too */
  if(header->number_of_timers == 0){
    /* Update the link list of headers */
    if(header->next!=NULL)
      header->next->prev = header->prev;
    if(header->prev!=NULL)
      header->prev->next = header->next;

    /* If this header is the first in the link list of headers, update the hash table entry also */
    if(timer_ds.hash_table[header->bucket_number] == header)
      timer_ds.hash_table[header->bucket_number] = header->next;
    
    /* Free the memory of the header */
    free_mem(header);

  }
  /* Free the memory of the timer */
  free_mem(handle);

  /* Release the lock */
  pthread_mutex_unlock(&timer_ds.currenttime_mutex);
  
}
예제 #19
0
파일: fmfield.c 프로젝트: certik/sfepy
/*!
  @par Revision history:
  - 06.02.2001, c
  - 06.03.2003, adopted from rcfem2
  - 20.03.2003
*/
int32 fmf_freeDestroy( FMField **p_obj )
{
  if ((*p_obj) == 0) return( RET_OK );

  fmf_free( *p_obj );
  free_mem( *p_obj );

  return( RET_OK );
}
예제 #20
0
void
stumpless_destroy_element( struct stumpless_element *element ) {
  size_t i;

  clear_error(  );

  if( !element ) {
    return;
  }

  for( i = 0; i < element->param_count; i++ ) {
    stumpless_destroy_param( element->params[i] );
  }

  free_mem( element->params );
  free_mem( element->name );
  free_mem( element );
}
예제 #21
0
void end_gspell( CHAR_DATA * ch ) {
  if ( !ch->gspell ) {
    bug( "end_gspell: no gspell", 0 );
    return;
  }

  free_mem( ch->gspell, sizeof( *ch->gspell ) );
  ch->gspell = NULL;
}
예제 #22
0
// Set format for date / time labels.
void
c_pltimefmt( PLCHAR_VECTOR fmt )
{
    if ( plsc->timefmt )
        free_mem( plsc->timefmt );

    plsc->timefmt = (char *) malloc( (size_t) ( strlen( fmt ) + 1 ) );
    strcpy( plsc->timefmt, fmt );
}
int main(int argc, char *argv[])
{
    FILE *code_file;
    int max_steps = 10000;

    // edit by leo
    init_sharemem();
    // edit end
	

    state_ptr s = new_state(MEM_SIZE);
    
    mem_t saver = copy_reg(s->r);
    mem_t savem;
    int step = 0;

    stat_t e = STAT_AOK;

    if (argc < 2 || argc > 3)
	usage(argv[0]);
    code_file = fopen(argv[1], "r");
    if (!code_file) {
	fprintf(stderr, "Can't open code file '%s'\n", argv[1]);
	exit(1);
    }
    
    if (!load_mem(s->m, code_file, 1)) {
	printf("Exiting\n");
	return 1;
    }    
    savem = copy_mem(s->m);
  
    // edit by leo
    // printf("error happen after here!\n");
    // edit end
    if (argc > 2)
	max_steps = atoi(argv[2]);

    for (step = 0; step < max_steps && e == STAT_AOK; step++)
	e = step_state(s, stdout);
    
    
    printf("Stopped in %d steps at PC = 0x%x.  Status '%s', CC %s\n",
	   step, s->pc, stat_name(e), cc_name(s->cc));

    printf("Changes to registers:\n");
    diff_reg(saver, s->r, stdout);

    printf("\nChanges to memory:\n");
    diff_mem(savem, s->m, stdout);

    free_state(s);
    free_reg(saver);
    free_mem(savem);

    return 0;
}
예제 #24
0
bool_t free_stringlist(stringlist_t *sl) {
  if( sl ) {
    if( sl->list ) {
      reset_stringlist(sl);
      free_mem(&sl->list, &sl->max);
    }
  }
  return FALSE;
}
예제 #25
0
void
free_format_data (st_parameter_dt *dtp)
{
  fnode_array *fa, *fa_next;
  format_data *fmt = dtp->u.p.fmt;

  if (fmt == NULL)
    return;

  for (fa = fmt->array.next; fa; fa = fa_next)
    {
      fa_next = fa->next;
      free_mem (fa);
    }

  free_mem (fmt);
  dtp->u.p.fmt = NULL;
}
예제 #26
0
파일: timer.c 프로젝트: RAHUL04/RIPv1
/* Funtion to reset the timer.
   Parameter : 
   1) handle  : Address of timer structure returned by start_timer 
*/
timer_info_ptr_t reset_timer(timer_info_ptr_t handle)
{
  timer_time_t current_endtime;
  timer_header_ptr_t new_header;
  timer_header_ptr_t curr_header;
  int position;

  /* Mutex to make changes to hash table and other data structures related to timer */
  pthread_mutex_lock(&timer_ds.currenttime_mutex);

  /* Calculating which bucket to insert into */
  position = get_position(handle->duration,&current_endtime);

  /* Remove the timer from present link list */
  if(handle->next != NULL)
    handle->next->prev = handle->prev;
  if(handle->prev != NULL)
    handle->prev->next = handle->next;

  /* Obtain the header of this timer */
  curr_header = handle->up;
  curr_header->number_of_timers--;
  if(curr_header->down == handle)
    curr_header->down = handle->next;
  
  /* If the timer is the only timer under its header */
  if(curr_header->number_of_timers == 0){
   
    /* If the header is the first in the list */
    if(timer_ds.hash_table[curr_header->bucket_number] == curr_header){
      timer_ds.hash_table[curr_header->bucket_number] = curr_header->next;  
    }
    
    if(curr_header->next != NULL)
      curr_header->next->prev = curr_header->prev;
    if(curr_header->prev != NULL)
      curr_header->prev->next = curr_header->next;
   
    new_header = get_header(position, current_endtime, curr_header);
    if(new_header != curr_header)
      free_mem(curr_header);
  }
  else
    /* Scanning the linked list of headers corresponding to the position in hash table */
    new_header =  get_header(position,current_endtime,NULL);
  
  if(new_header == NULL)
    return(NULL);

  /* Attach the new timer to link list of the header */
  attach_timer_to_header(handle,new_header);

  /* Release the lock */
  pthread_mutex_unlock(&timer_ds.currenttime_mutex);

  return(handle);
}
예제 #27
0
파일: friction.c 프로젝트: Comanche93/eech
void apply_friction_forces (int index)
{

	constraint_forces
		*destroy_cf,
		*cf;

	cf = friction_force_list_head;

	while (cf)
	{

		cf->owner->linear_force [index].x += cf->force.x;
		cf->owner->linear_force [index].y += cf->force.y;
		cf->owner->linear_force [index].z += cf->force.z;

		cf->owner->torque [index].x += cf->torque.x;
		cf->owner->torque [index].y += cf->torque.y;
		cf->owner->torque [index].z += cf->torque.z;

		#if DEBUG_MODULE

		if (cf->owner == camera_object->rigid_body)
		{
/*	
			double_vec3d
				temp_direction,
				temp_position;
	
			temp_position.x = cf->owner->position_cm [0].x;
			temp_position.y = cf->owner->position_cm [0].y;
			temp_position.z = cf->owner->position_cm [0].z;
	
			temp_direction = cf->force;
			normalise_any_3d_double_vector (&temp_direction);
	
			create_arrow ("TAIL_ARROW", &temp_position, &temp_direction, 6.0);
*/
			debug_log ("BODY: FRICTION: Applying %s force [%f, %f, %f] torque [%f, %f, %f]",
						cf->owner->name,
						cf->force.x, cf->force.y, cf->force.z,
						cf->torque.x, cf->torque.y, cf->torque.z);

		}

		#endif

		destroy_cf = cf;

		cf = cf->next;

		free_mem (destroy_cf);
	}

	friction_force_list_head = NULL;
}
예제 #28
0
파일: player.c 프로젝트: ryjen/muddled
void destroy_player(Player *p)
{
    free_str(p->title);
    free_str(p->prompt);
    free_str(p->battlePrompt);
    destroy_flags(p->explored);
    destroy_flags(p->channels);
    free_mem(p);

}
예제 #29
0
파일: db.c 프로젝트: MUDOmnibus/Merc21
/*
 * Free a string.
 * Null is legal here to simplify callers.
 * Read-only shared strings are not touched.
 */
void free_string( char *pstr )
{
    if ( pstr == NULL
    ||   pstr == &str_empty[0]
    || ( pstr >= string_space && pstr < top_string ) )
	return;

    free_mem( pstr, strlen(pstr) + 1 );
    return;
}
예제 #30
0
/**********************************************************************
 * memfree
 *
 * Memory allocator with protection.
 **********************************************************************/
void memfree(void *element) {
  if (element) {
    free_mem(element);
    mem_alloc_counter--;
  }
  else {
    tprintf ("%d MEM_ALLOC's used\n", mem_alloc_counter);
    DoError (0, "Memfree of NULL pointer");
  }
}