コード例 #1
0
ファイル: bl.c プロジェクト: blackball/an-test6
void bl_append_list(bl* list1, bl* list2) {
	list1->last_access = NULL;
	list1->last_access_n = 0;
	if (list1->datasize != list2->datasize) {
		printf("Error: cannot append bls with different data sizes!\n");
		assert(0);
		exit(0);
	}
	if (list1->blocksize != list2->blocksize) {
		printf("Error: cannot append bls with different block sizes!\n");
		assert(0);
		exit(0);
	}

	// if list1 is empty, then just copy over list2's head and tail.
	if (list1->head == NULL) {
		list1->head = list2->head;
		list1->tail = list2->tail;
		list1->N = list2->N;
		// remove everything from list2 (to avoid sharing nodes)
		clear_list(list2);
		return;
	}

	// if list2 is empty, then do nothing.
	if (list2->head == NULL)
		return;

	// otherwise, append list2's head to list1's tail.
	list1->tail->next = list2->head;
	list1->tail = list2->tail;
	list1->N += list2->N;
	// remove everything from list2 (to avoid sharing nodes)
	clear_list(list2);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: grafin/my_shell
int main( int argc, char** argv) {

    int ch = 0;
    char buf[STR_SIZE] = {};
    char* hisBuf = NULL;
    char str[STR_SIZE] = {};
    char historyArr[HISTORY_SIZE][STR_SIZE] = {};
    int inHistory = 0;
    int cmd = -1;

    List_t* list = new_list( );
    while( true) {
        getcwd( str, STR_SIZE);
        printf( "%s> ", str);

        fgets( buf, STR_SIZE, stdin);
        if( feof( stdin)) {
            printf( "logout\n");
            break;
        }
        if( buf[0] == '\n')
            continue;

        parse_program( list, buf);

        if( (cmd = commands( list->head->next->program)) >= 0) {
            switch( cmd) {
                case logout:
                    goto finish;
                    break;
                case cd:
                    if( chdir( list->head->next->program->arguments[0]) < 0)
                        warn( "Error while changing dir");
                    break;
                case history:
                    if( list->head->next->program->arguments[0][0]) {
                        hisBuf = get_history( historyArr, atoi( list->head->next->program->arguments[0]), inHistory);
                        if( hisBuf) {
                            strcpy( buf, hisBuf);
                            clear_list( list);
                            parse_program( list, buf);
                            printf( "%s\n", buf);
                            execute( list);
                        }
                    } else
                        dump_history( historyArr, inHistory);
                    break;
            }
        } else
            execute( list);
        if( cmd != history)
            inHistory = add_in_history( historyArr, buf, inHistory);
        clear_list( list);
    }

finish:
    destroy_list( list);
    return 0;
}
コード例 #3
0
void
clear_inferiors (void)
{
  for_each_inferior (&all_threads, free_one_thread);
  for_each_inferior (&all_dlls, free_one_dll);

  clear_list (&all_threads);
  clear_list (&all_dlls);

  current_inferior = NULL;
}
コード例 #4
0
ファイル: vm_destroy.c プロジェクト: sabs231/corewar
int		destroy_vm(t_vm *vm, t_list **files)
{
  int		ret;

  apply_in_list(vm->warriors, &free);
  clear_list(&vm->warriors);
  free_registers(vm);
  apply_in_list(vm->processes, &free);
  clear_list(&vm->processes);
  if ((ret = close_files(*files)) != SUCCESS)
    return (ret);
  apply_in_list(*files, &free);
  clear_list(files);
  return (SUCCESS);
}
コード例 #5
0
ファイル: lua-netpack.c プロジェクト: KAndQ/skynet
// 释放 struct queue
// lua: 接受 1 个参数, userdata 类型, 表示 struct queue; 0 个返回值.
static int
lclear(lua_State *L) {
	struct queue * q = lua_touserdata(L, 1);
	if (q == NULL) {
		return 0;
	}

	// 释放 struct uncomplete
	int i;
	for (i = 0; i < HASHSIZE; i++) {
		clear_list(q->hash[i]);
		q->hash[i] = NULL;
	}

	// 方便后面的运算, 直接取余就好了
	if (q->head > q->tail) {
		q->tail += q->cap;
	}

	// 释放 netpack.buffer 指向的资源
	for (i=q->head;i<q->tail;i++) {
		struct netpack *np = &q->queue[i % q->cap];
		skynet_free(np->buffer);
	}
	q->head = q->tail = 0;

	return 0;
}
コード例 #6
0
ファイル: DataNode.c プロジェクト: WHUinTAMU/MotionNetProject
void free_list(DataHeadNode *pHead) {
    clear_list(pHead);
    if(pHead != NULL)
        free(pHead);
    pHead = NULL;
    printf("free data list done\n");
}
コード例 #7
0
ファイル: main.c プロジェクト: Zziwei/MotionNet
//1. collect initial data in MAG_CALI_TIME seconds
//2. do calibration for initial data
//3. if calibrator is invalid, repeat step 1.
void initCalibrator(HANDLE hComm) {
    printf("\n=========================  Initialize Calibrator  =====================\n");
    PktData pktData;

    //Mag data list for initialization
    DataHeadNode *ptr = create_list_with_head();
    int len;

    while (true) {
        printf("\nCollect data in the next %d seconds!\n", MAG_CALI_TIME);

        //Before read, flush the buffer.
        purgePort(hComm);

        time_t timeBegin = time(NULL);

        while (true) {
            pktData = blockingReadOnePacket(hComm);

            if(equals(pktData, ZERO_PKT)) {
                continue;
            }
            add_to_list_head(ptr, pktData);

            if(time(NULL) - timeBegin >= MAG_CALI_TIME)
                break;
        }

        //Start prepare double array for calculate calibrator
        len = ptr->length;
        printf("Initialize data length: %d \n", len);

        double magDataX[len] ;
        double magDataY[len] ;
        double magDataZ[len] ;
        double heading[len];

        fillMagDataArray(ptr, magDataX, magDataY, magDataZ);

        //pass magData to calibrator
        calculateCalibrator(magDataX, magDataY, magDataZ, len);

        write_list_to_file("C:/Users/xing/Desktop/Raw_Initial_Data.txt", ptr);

        if(! calibrateMagData(magDataX, magDataY, magDataZ, heading, len))
            continue;

        write_mag_to_file("C:/Users/xing/Desktop/Corrected_Initial_Mag_Data.txt", magDataX, magDataY, magDataZ, heading, len);

        clear_list(ptr);

        if(isCalibratorValid(magDataX, magDataY, magDataZ, len))
            break;
    }

    //free all list data
    free_list(ptr);
    isCalibratorInitialized = true;
    printf("\n============================  Initialize Over  ========================\n");
}
コード例 #8
0
ファイル: List.c プロジェクト: showpointer/Algorithm
int main() {
    int n;
    scanf("%d", &n);

    list mylist;
    init_list(&mylist);
    while(n--) {
        char command[10];
        scanf("%s", command);

        // push, get, size, count, clear
        if(command[0] == 'p') {
            int value;
            scanf("%d", &value);
            push_back(&mylist, value);
        } else if(command[0] == 'g') {
            int idx;
            scanf("%d", &idx);
            printf("%d\n", get_idx(&mylist, idx));
        } else if(command[0] == 's') {
            printf("%d\n", mylist.size);
        } else if(command[1] == 'o') {
            int target;
            scanf("%d", &target);
            printf("%d\n", count_target(&mylist, target));
        } else {
            clear_list(&mylist);
        }
    }

    return 0;
}
コード例 #9
0
ファイル: omg.c プロジェクト: ShibinMathew36/OAI-step
/*stop sumo mobiity generator*/
void
stop_mobility_generator (omg_global_param * omg_param_list)
{
  int i;

  for (i = 0; i < MAX_NUM_NODE_TYPES; i++) {
    switch (omg_param_list[i].mobility_type) {

    case STATIC:
      break;

    case RWP:
      break;

    case RWALK:
      break;

    case TRACE:
      clear_list ();
      break;

    case STEADY_RWP:
      break;
#ifdef SUMO_IF
    case SUMO:
      stop_sumo_generator ();
      //LOG_D(OMG," --------OMG will interface with SUMO for mobility generation-------- \n");
      break;
#endif 
    default:
      LOG_N (OMG, "Unsupported generator\n");
    }
  }

}
コード例 #10
0
ファイル: main.cpp プロジェクト: zbxzc35/my_adaboost
void generate_validate_samples(std::vector<std::string> &imgList, int WIDTH, int HEIGHT, std::list<float*> &validateSet, int size)
{
    assert(size < imgList.size());

    if(validateSet.size() > 0)
        clear_list(validateSet);

    for(int i = 0 ; i < size; i++)
    {
        cv::Mat img = cv::imread(imgList[i], 0);
        cv::Mat sImg;

        if(img.empty())
        {
            printf("Can't open image %s\n", imgList[i].c_str());
            exit(0);
        }

        cv::resize(img, sImg, cv::Size(WIDTH, HEIGHT));

        float *data = mat_to_float(sImg);

#ifdef USE_HAAR_FEATURE
        integral_image(data, WIDTH, HEIGHT);
#endif

        validateSet.push_back(data);
    }
}
コード例 #11
0
ファイル: PrivPtr.cpp プロジェクト: PICCO-Team/picco
void PrivPtr::set_ptr(priv_ptr assign_ptr, priv_ptr right_ptr, int threadID)
{
	clear_list(&(assign_ptr->list)); 
	copy_list(assign_ptr->list, right_ptr->list, right_ptr->level-1, assign_ptr->type);
	assign_ptr->size = right_ptr->size; 
	assign_ptr->level = right_ptr->level;  
}
コード例 #12
0
ファイル: los.c プロジェクト: liutanyu/larceny-0.97-src
static void append_and_clear( los_list_t *left, los_list_t *right )
{
  word *left_first = next( left->header );
  word *left_last = prev( left->header );
  word *right_first = next( right->header );
  word *right_last = prev( right->header );

  if (right_first == right->header) return;   /* Right is empty */

  /* Splice in the right list */
  if (left_first != left->header) {           /* Left is nonempty  */
    set_next( left_last, right_first );       /* Join lists */
    set_prev( right_first, left_last );
  }
  else {			              /* Left is empty */
    set_next( left->header, right_first );    /* Move right to left */
    set_prev( right_first, left->header );
  }

  /* Complete circle */
  set_next( right_last, left->header );
  set_prev( left->header, right_last );

  left->bytes += right->bytes;
  clear_list( right );
}
コード例 #13
0
void ProxyConfig::fillClients()
{
    m_current = (unsigned)(-1);
    m_data.clear();
    cmbClient->clear();
    cmbClient->insertItem(i18n("Default"));
    ProxyData d(m_plugin->data);
    clear_list(&d.Clients);
    m_data.push_back(d);
    for (unsigned i = 0; i < getContacts()->nClients(); i++){
        Client *client = getContacts()->getClient(i);
        if (client->protocol()->description()->flags & PROTOCOL_NOPROXY)
            continue;
        QString name = client->name().c_str();
        int pos = name.find(".");
        if (pos > 0)
            name = name.replace(pos, 1, " ");
        cmbClient->insertItem(Pict(client->protocol()->description()->icon), name);
        ProxyData d;
        m_plugin->clientData(static_cast<TCPClient*>(client), d);
        m_data.push_back(d);
    }
    bool bState;
    if (!get_connection_state(bState)){
        cmbClient->insertItem(i18n("HTTP requests"));;
        ProxyData d;
        m_plugin->clientData((TCPClient*)(-1), d);
        m_data.push_back(d);
    }
    clientChanged(0);
}
コード例 #14
0
/*
 * Updates all the neighborlists during subsequent iterations
 *
 * arguments:
 *      particles:  The spatially decomposed particle information
 *      neighbors:  The array of all neighbor lists
 *      moved_lists:The list of particles that have moved between iterations
 *      counts:     The number of particles in each moved list
 *      my_rank:    The rank of the node
 */
void update_neighbor_lists(Particle* particles[XDiv][YDiv][ZDiv], Neighbor** neighbors, Particle** moved_list[XDiv][YDiv][ZDiv], int counts[XDiv][YDiv][ZDiv], int my_rank){
    //Iterate through all the particles in all the blocks
    //If a particles has moved, then do a full rebuild of its neighbor list
    //Otherwise, look at the particles that have moved, and update the list
    int x, y, z, i;
    int rank = my_rank - 1;
    int tag = 0;
    Particle p;
    for (x = node_boundries[rank][0]; x <= node_boundries[rank][1]; ++x) {
        for (y = node_boundries[rank][2]; y <= node_boundries[rank][3]; ++y) {
            for (z = node_boundries[rank][4]; z <= node_boundries[rank][5]; ++z) {
                
                #pragma omp for private(p)
                for (i = 0; i < block_size; ++i){
                    p = particles[x][y][z][i];
                    if (p.index != -1) {
                        if (p.moved){
                            clear_list(neighbors[tag+i]);
                            build_list_full(particles, neighbors[tag+i], x, y, z, i);
                        }
                        else {
                            remove_moved_particles(neighbors[tag+i]);
                            update_list(particles, neighbors[tag+i], x, y, z, i, moved_list, counts);
                        }
                    }
                }
                tag = tag + block_size;
            }
        }
    }
}
コード例 #15
0
/* add an entry to the history list */
void packet_history_add(gint row) {

    if(row < 1) {
        /* Not a valid row number */
        return;
    }

    if(ignore_jump) {
        /* we jumping back and forward in history, so don't change list */
        return;
    }

    if (history_current) {
        /* clear list behind current position */
        clear_list(g_list_next(history_current));

        /* ignore duplicates */
        if(GPOINTER_TO_INT(history_current->data) == row) {
            adjust_menus();
            return;
        }
    }

    /* add row */
    history_list = g_list_append(history_list, GINT_TO_POINTER(row));
    history_current = g_list_last(history_list);

    adjust_menus();
}
コード例 #16
0
ファイル: Func.cpp プロジェクト: aodpi/Pharmacy
void display(int needfile)
{
	if (needfile == 1)
	{
		read_from_file();
	}
	Node* tmp = root;
	int ind = 1;
	print_deco(75,'+');
	printf("\t\t|ID |Nume       |Pret       |Prescriptie medicala   |Tip medicament       |");
	printf("\n");
	print_deco(75,'+');
	while (root->next != NULL)
	{
		root = root->next;
		printf("\t\t|%-3d|%-10s |%-10d |%-22s |%-21s| \n", ind++, root->data.nume, root->data.pret, root->data.pr_med, root->data.tip);
		print_deco(75,'=');
	}	
	printf("\n");
	root = tmp;
	if (needfile==1)
	{
		clear_list();
	}
}
コード例 #17
0
ファイル: PrivPtr.cpp プロジェクト: PICCO-Team/picco
void PrivPtr::set_ptr(priv_ptr ptr, mpz_t* int_var_loc, mpz_t** float_var_loc, void* struct_var_loc, priv_ptr* ptr_loc, int threadID)
{
	listnode node = create_listnode(); 
	if(int_var_loc != NULL)
	{
		node->u.int_var_location = int_var_loc;
		ptr->level = 1; 
	}
	else if(float_var_loc != NULL)
	{
		node->u.float_var_location = float_var_loc; 
		ptr->level = 1;  
	}
	else if(struct_var_loc != NULL)
	{
		node->u.struct_var_location = struct_var_loc; 
		ptr->level = 1; 
	}
	else
	{
		node->u.ptr_location = *ptr_loc;
		ptr->level = (*ptr_loc)->level; 
	} 
	clear_list(&(ptr->list));
	node->if_index = -1;
	mpz_set_ui(node->priv_tag, 1); 
	insert_to_rear(ptr->list, node); 
	ptr->size = 1; 
}
コード例 #18
0
ファイル: alarm.c プロジェクト: k-takata/TClockLight
/*------------------------------------------------
  initialize
--------------------------------------------------*/
void InitAlarm(void)
{
	ALARMSTRUCT item;
	PALARMSTRUCT pitem;
	int jihou;
	
	clear_list(m_pAlarm);
	m_pAlarm = NULL;
	
	jihou = 0;
	if(GetMyRegLong("", "Jihou", FALSE)) jihou = 1;
	
	// read settings
	m_pAlarm = LoadAlarm(); // common/alarmstruct.c
	
	// cuckoo clock
	if(jihou)
	{
		memset(&item, 0, sizeof(ALARMSTRUCT));
		strcpy(item.name, "cuckoo");
		strcpy(item.strHours, "*");
		strcpy(item.strMinutes, "0");
		strcpy(item.strWDays, "*");
		SetAlarmTime(&item); // common/alarmstruct.c
		
		item.bEnable = TRUE;
		item.bHour12 = TRUE;
		GetMyRegStr("", "JihouFile", item.fname, MAX_PATH, "");
		if(GetMyRegLong("", "JihouRepeat", FALSE))
			item.bRepeatJihou = TRUE;
		if(GetMyRegLong("", "JihouBlink", FALSE))
		{
			item.bBlink = TRUE; item.nBlinkSec = 60;
		}
		
		m_pAlarm = copy_listitem(m_pAlarm, &item, sizeof(item));
	}
	
	m_bCheckEverySeconds = FALSE;
	pitem = m_pAlarm;
	while(pitem)
	{
		if(pitem->bEnable)
		{
			if(pitem->second)
				m_bCheckEverySeconds = TRUE;
			else if(pitem->bInterval)
			{
				if(!pitem->bBootExec)
					pitem->tickLast = GetTickCount();
				m_bCheckEverySeconds = TRUE;
			}
			if(pitem->bResumeExec)
				m_bCheckEverySeconds = TRUE;
		}
		
		pitem = pitem->next;
	}
}
コード例 #19
0
ファイル: solution.c プロジェクト: redo007/chess_with_chest
    static void
sol_1move_list( Move* mp, Bool valid, Movelist* sols )
{
    clear_list(sols);
    if( mp && valid && !no_pos(mp->m_from) ) {
	app_move(mp, sols);
    }
    mg_link(sols);
}
コード例 #20
0
void MenuConfig::apply(void *_data)
{
    ActionUserData *data = (ActionUserData*)_data;
    clear_list(&data->Menu);
    data->NMenu.value = 0;
    for (QListViewItem *item = lstMenu->firstChild(); item; item = item->nextSibling()) {
        set_str(&data->Menu, ++data->NMenu.value, (item->text(0) + ";" + item->text(1)).utf8());
    }
}
コード例 #21
0
ファイル: gtk.c プロジェクト: samhorlbeck/boggle-solver
void clear_clicked(GtkButton *button, gpointer data)
{
    int x, y;
    for(x = 0; x < 4; x++)
        for(y = 0; y < 4; y++)
            gtk_entry_set_text(GTK_ENTRY(textboxes[x][y]), "");

    clear_list(list);
}
コード例 #22
0
ファイル: TestList.c プロジェクト: Blurred-9L/NodesAndLinks
int main(){
    List list;
    List list2;
    int i;
    
    init_list( &list );
    printf( "Empty: %d\n", empty_list( list ) );
    for( i = 1; i <= 5; i++ ){
        append_node( &i, sizeof( int ), list );
        printf( "Length: %d | ", length( list ) );
        print_list( list );
    }
    for( i = 6; i <= 10; i++ ){
        insert_front( &i, sizeof( int ), list );
        printf( "Length: %d | ", length( list ) );
        print_list( list );
    }
    printf( "Empty: %d\n", empty_list( list ) );
    printf( "First: %d\n", get_int( list_op_first( list ) -> data ) );
    printf( "Last:  %d\n", get_int( list_op_last( list ) -> data ) );
    printf( "Second to last: %d\n", get_int( list_op_prev( list_op_last( list ), list ) -> data ) );
    printf( "Second element: %d\n", get_int( get_elem_at( 1, list ) -> data ) );
    
    place_after( &i, sizeof( int ), get_elem_at( 1, list ), list );
    print_list( list );
    i++;
    insert_at( &i, sizeof( int ), 2, list );
    print_list( list );
    i++;
    insert_at( &i, sizeof( int ), 0, list );
    print_list( list );
    
    init_list( &list2 );
    for( i = 100; i > 95; i-- ){
        insert_front( &i, sizeof( int ), list2 );
    }
    append_list( list, &list2 );
    free( list2 );
    print_list( list );
    
    printf( "Erasing 5th element...\n" );
    erase_at( 4, list );
    print_list( list );
    printf( "Erasing 1st element...\n" );
    erase_at( 0, list );
    print_list( list );
    printf( "Erasing last element...\n" );
    erase_node( list_op_last( list ), list );
    print_list( list );
    printf( "Erasing 3rd element...\n" );
    erase_node( get_elem_at( 2, list ), list );
    print_list( list );
    
    clear_list( &list );
    
    return 0;
}
コード例 #23
0
ファイル: trans.c プロジェクト: MKontra/projects-fit
void 
free_list ( transaction_list_ptr list )
{
	if ( list == NULL ) return;

	clear_list ( list );

	free (list); 

}
コード例 #24
0
ファイル: plist.c プロジェクト: mtsuszycki/whowatch
static void ptree_hide(struct wdgt *w)
{
	DBG("Deleting ptree  from lists");
	w->redraw = w->wrefresh = 0;
	clear_list();
	w->periodic = 0;
	w->msgh = 0;
	ptreeinfo(w, 0);
	bzero(&pstat, sizeof pstat);
}	
コード例 #25
0
ファイル: content_type.c プロジェクト: rhoffmann8/cs631
void
delete_content_type(struct content_type *ctypeptr) {

	if (ctypeptr->ctype)
		free(ctypeptr->ctype);
	clear_list(ctypeptr->exts);

	free(ctypeptr);
	ctypeptr = NULL;
}
コード例 #26
0
ファイル: dialog.c プロジェクト: k-takata/TClockLight
/*------------------------------------------------
   clear up
--------------------------------------------------*/
void OnDestroy(HWND hDlg)
{
	g_hDlg = NULL;
	
	clear_list(m_pTimer);
	m_pTimer = NULL;
	m_nCurrent = -1;
	
	StopFile();
	m_bPlaying = FALSE;
}
コード例 #27
0
ファイル: los.c プロジェクト: liutanyu/larceny-0.97-src
static los_list_t *make_los_list( void )
{
  los_list_t *list;

  list = (los_list_t*)must_malloc( sizeof( los_list_t ) );
  list->header = (word*)must_malloc( HEADER_WORDS*sizeof(word) )+HEADER_WORDS;
  set_size( list->header, 0 );
  clear_list( list );

  return list;
}
コード例 #28
0
ファイル: dlg_girls.cpp プロジェクト: kingstop/crashmo
void dlg_girls::load_girls()
{
	clear_list();
	MAPGIRLS::iterator it = g_girls_manager._girls.begin();
	for (; it != g_girls_manager._girls.end(); ++it)
	{
		girl_info* entry = it->second;
		_girls_list.AddString(entry->card_.c_str());
	}
	update_edit();
}
コード例 #29
0
void packet_history_clear(void) {

    /* clear "old" list */
    clear_list(history_list);
    history_current = NULL;

    /* add the currently selected first row */
    packet_history_add(0);

    adjust_menus();
}
コード例 #30
0
ファイル: linkedlist.c プロジェクト: hailuy/os_week09
int main(){
  llist* my_list=NULL;		/* Pointer to an empty list */
  int i=0;

  for (i=0;i<5;i++)           /* loop to build the list */
	 my_list = add_list(my_list,i,i, i*1.0f);   /* add an item to list */

  print_list(my_list);			
  my_list = clear_list(my_list);
  
}