示例#1
0
// free all stainfo which in sta_hash[all]
void free_all_stainfo(_adapter *padapter)
{
	_irqL	 irqL;
	_list	*plist, *phead;
	s32	index;
	struct sta_info *psta = NULL;
	struct	sta_priv *pstapriv = &padapter->stapriv;
	struct sta_info* pbcmc_stainfo =get_bcmc_stainfo( padapter);
	
_func_enter_;	

	if(pstapriv->asoc_sta_count==1)
		goto exit;

	_enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);

	for(index=0; index< NUM_STA; index++)
	{
		phead = &(pstapriv->sta_hash[index]);
		plist = get_next(phead);
		
		while ((end_of_queue_search(phead, plist)) == _FALSE)
		{
			psta = LIST_CONTAINOR(plist, struct sta_info ,hash_list);

			plist = get_next(plist);

			if(pbcmc_stainfo!=psta)					
				free_stainfo(padapter , psta);
			
		}
	}
	
	_exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
	
exit:	
	
_func_exit_;	

}
示例#2
0
/*
	return the wlan_network with the matching addr
	Shall be calle under atomic context...
	to avoid possible racing condition...
*/
static struct wlan_network *_r8712_find_network(struct  __queue *scanned_queue,
					 u8 *addr)
{
	unsigned long irqL;
	struct list_head *phead, *plist;
	struct wlan_network *pnetwork = NULL;
	u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};

	if (!memcmp(zero_addr, addr, ETH_ALEN))
		return NULL;
	spin_lock_irqsave(&scanned_queue->lock, irqL);
	phead = get_list_head(scanned_queue);
	plist = get_next(phead);
	while (plist != phead) {
		pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
		plist = get_next(plist);
		if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
			break;
	}
	spin_unlock_irqrestore(&scanned_queue->lock, irqL);
	return pnetwork;
}
示例#3
0
文件: utilities.c 项目: di/school
pair find_mutex_facts(hashtable_t harr[], int time)
{
  static int flag = 0;
  pair retval;
  edgelist_t e;
  vertex_t v;
  int i, j, fcount=0, ecount=0;
  if (flag == 0) {  /* doing this since MAXNODES is not a constant */
    varr = (vertex_t *) malloc(MAXNODES*sizeof(vertex_t));
    flag = 1;
  }
  get_next(harr[time],0); /* initialize */
  for(i=0; (varr[i] = get_next(harr[time],1)) != NULL; ++i);
  for(i=0; varr[i] != NULL; ++i) {
    ++fcount;
    /* if it's NEW, then check against everybody */
    if (!varr[i]->prev_time) {
      for(j=0; varr[j] != NULL; ++j) {
	if (!varr[j]->prev_time && j <= i) continue; /* already checked */
	if (are_facts_exclusive(varr[i], varr[j])) {
	  ++ecount;
	  do_exclusive(varr[i], varr[j]);
	}
      }
    } else { /* OLD, so only check previous exclusives */
      for(e = varr[i]->prev_time->exclusive; e; e = e->next) {
	v = e->endpt->next_time;
	if ((int) v < (int) varr[i]) continue;  /* get in other direction */
	if (are_facts_exclusive(varr[i], v)) {
	  ++ecount;
	  do_exclusive(varr[i], v);
	}
      }
    }
  }
  retval.first = fcount;
  retval.second = ecount;
  return retval;
}
示例#4
0
static struct stats_record *get_next_record(struct stats_iter *iter)
{
	if (iter->it != iter->end) {
		struct stats_record *tmp;

		tmp = iter->it;
		iter->it = get_next(iter->file, iter->it);

		return tmp;
	}

	return NULL;
}
示例#5
0
node* find_by_data(linkedlist_t* list, void* data)
{
    node* slider;
    slider = get_head(list);
    for(; NULL != slider;)
    {
        if(slider->data == data)
            break;

        slider = get_next(slider);
    }
    return slider;
}
示例#6
0
/* any station allocated can be searched by hash list */
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
{
	struct list_head	*plist, *phead;
	struct sta_info *psta = NULL;
	u32 index;
	u8 *addr;
	u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

	if (!hwaddr)
		return NULL;

	if (IS_MCAST(hwaddr))
		addr = bc_addr;
	else
		addr = hwaddr;

	index = wifi_mac_hash(addr);

	spin_lock_bh(&pstapriv->sta_hash_lock);

	phead = &(pstapriv->sta_hash[index]);
	plist = get_next(phead);


	while (phead != plist) {

		psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);

		if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)))
		 /*  if found the matched address */
			break;

		psta = NULL;
		plist = get_next(plist);
	}

	spin_unlock_bh(&pstapriv->sta_hash_lock);
	return psta;
}
示例#7
0
// free all stainfo which in sta_hash[all]
void rtw_free_all_stainfo(_adapter *padapter)
{
	_list	*plist, *phead;
	s32	index;
	struct sta_info *psta = NULL;
	struct	sta_priv *pstapriv = &padapter->stapriv;
	struct sta_info* pbcmc_stainfo =rtw_get_bcmc_stainfo( padapter);

_func_enter_;

	if(pstapriv->asoc_sta_count==1)
		goto exit;

	spin_lock_bh(&pstapriv->sta_hash_lock);

	for(index=0; index< NUM_STA; index++)
	{
		phead = &(pstapriv->sta_hash[index]);
		plist = get_next(phead);

		while (phead != plist)
		{
			psta = LIST_CONTAINOR(plist, struct sta_info ,hash_list);

			plist = get_next(plist);

			if(pbcmc_stainfo!=psta)
				rtw_free_stainfo(padapter , psta);

		}
	}

	spin_unlock_bh(&pstapriv->sta_hash_lock);

exit:

_func_exit_;

}
示例#8
0
void SequenceExtension::link( void )
{
  /* Make sure sequence paramenters don't change */
  MPEGHeader *hdr = get_next();
  while ( hdr ) {
    if ( SequenceExtension *ts = dynamic_cast<SequenceExtension *>( hdr ) ) {
      mpegassert( *this == *ts );
      break;
    } else {
      hdr = hdr->get_next();
    }
  }
}
示例#9
0
int qmi_parse_wms_raw_read_response(struct qmi_msg *msg, struct qmi_wms_raw_read_response *res)
{
    void *tlv_buf = &msg->svc.tlv;
    int tlv_len = le16_to_cpu(msg->svc.tlv_len);
    struct tlv *tlv;
    int i;

    memset(res, 0, sizeof(*res));

    __qmi_alloc_reset();
    while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) {
        unsigned int cur_tlv_len = le16_to_cpu(tlv->len);
        unsigned int ofs = 0;

        switch(tlv->type) {
        case 0x01:
            res->set.raw_message_data = 1;
            res->data.raw_message_data.message_tag = *(uint8_t *) get_next(1);
            res->data.raw_message_data.format = *(uint8_t *) get_next(1);
            i = le16_to_cpu(*(uint16_t *) get_next(2));
            res->data.raw_message_data.raw_data = __qmi_alloc_static(i);
            while(i-- > 0) {
                res->data.raw_message_data.raw_data[res->data.raw_message_data.raw_data_n] = *(uint8_t *) get_next(1);
                res->data.raw_message_data.raw_data_n++;
            }
            break;

        default:
            break;
        }
    }

    return 0;

error_len:
    fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\n",
            __func__, tlv->type, le16_to_cpu(tlv->len));
    return QMI_ERROR_INVALID_DATA;
}
示例#10
0
文件: player.c 项目: ayoucai/cmus
static void __consumer_handle_eof(void)
{
	struct track_info *ti;

	if (ip_is_remote(ip)) {
		__producer_stop();
		__consumer_drain_and_stop();
		player_error("lost connection");
		return;
	}

	if (player_repeat_current) {
		if (player_cont) {
			ip_seek(ip, 0);
			reset_buffer();
		} else {
			__producer_stop();
			__consumer_drain_and_stop();
			__player_status_changed();
		}
		return;
	}

	if (get_next(&ti) == 0) {
		__producer_unload();
		ip = ip_new(ti->filename);
		__producer_status_update(PS_STOPPED);
		/* PS_STOPPED, CS_PLAYING */
		if (player_cont) {
			__producer_play();
			if (producer_status == PS_UNLOADED) {
				__consumer_stop();
				track_info_unref(ti);
				file_changed(NULL);
			} else {
				/* PS_PLAYING */
				file_changed(ti);
				if (!change_sf(0))
					__prebuffer();
			}
		} else {
			__consumer_drain_and_stop();
			file_changed(ti);
		}
	} else {
		__producer_unload();
		__consumer_drain_and_stop();
		file_changed(NULL);
	}
	__player_status_changed();
}
示例#11
0
int qmi_parse_pds_get_gps_service_state_response(struct qmi_msg *msg, struct qmi_pds_get_gps_service_state_response *res)
{
	void *tlv_buf = &msg->svc.tlv;
	unsigned int tlv_len = le16_to_cpu(msg->svc.tlv_len);
	struct tlv *tlv;
	int i;
	uint32_t found[1] = {};

	memset(res, 0, sizeof(*res));

	__qmi_alloc_reset();
	while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) {
		unsigned int cur_tlv_len = le16_to_cpu(tlv->len);
		unsigned int ofs = 0;

		switch(tlv->type) {
		case 0x01:
			if (found[0] & (1 << 1))
				break;

			found[0] |= (1 << 1);
			res->set.state = 1;
			res->data.state.gps_service_state = *(uint8_t *) get_next(1);
			res->data.state.tracking_session_state = *(uint8_t *) get_next(1);
			break;

		default:
			break;
		}
	}

	return 0;

error_len:
	fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\n",
	        __func__, tlv->type, le16_to_cpu(tlv->len));
	return QMI_ERROR_INVALID_DATA;
}
示例#12
0
static krb5_error_code
kdc_get_next(krb5_context context,
	     struct krb5_krbhst_data *kd,
	     krb5_krbhst_info **host)
{
    krb5_error_code ret;

    if ((kd->flags & KD_PLUGIN) == 0) {
	plugin_get_hosts(context, kd, locate_service_kdc);
	kd->flags |= KD_PLUGIN;
	if(get_next(kd, host))
	    return 0;
    }

    if((kd->flags & KD_CONFIG) == 0) {
	config_get_hosts(context, kd, "kdc");
	kd->flags |= KD_CONFIG;
	if(get_next(kd, host))
	    return 0;
    }

    if (kd->flags & KD_CONFIG_EXISTS)
	return KRB5_KDC_UNREACH; /* XXX */

    if(context->srv_lookup) {
	if((kd->flags & KD_SRV_UDP) == 0 && (kd->flags & KD_LARGE_MSG) == 0) {
	    srv_get_hosts(context, kd, "udp", "kerberos");
	    kd->flags |= KD_SRV_UDP;
	    if(get_next(kd, host))
		return 0;
	}

	if((kd->flags & KD_SRV_TCP) == 0) {
	    srv_get_hosts(context, kd, "tcp", "kerberos");
	    kd->flags |= KD_SRV_TCP;
	    if(get_next(kd, host))
		return 0;
	}
	if((kd->flags & KD_SRV_HTTP) == 0) {
	    srv_get_hosts(context, kd, "http", "kerberos");
	    kd->flags |= KD_SRV_HTTP;
	    if(get_next(kd, host))
		return 0;
	}
    }

    while((kd->flags & KD_FALLBACK) == 0) {
	ret = fallback_get_hosts(context, kd, "kerberos",
				 kd->def_port, 
				 krbhst_get_default_proto(kd));
	if(ret)
	    return ret;
	if(get_next(kd, host))
	    return 0;
    }

    return KRB5_KDC_UNREACH; /* XXX */
}
示例#13
0
/**
 * insn_get_opcode - collect opcode(s)
 * @insn:	&struct insn containing instruction
 *
 * Populates @insn->opcode, updates @insn->next_byte to point past the
 * opcode byte(s), and set @insn->attr (except for groups).
 * If necessary, first collects any preceding (prefix) bytes.
 * Sets @insn->opcode.value = opcode1.  No effect if @insn->opcode.got
 * is already 1.
 */
void insn_get_opcode(struct insn *insn)
{
	struct insn_field *opcode = &insn->opcode;
	insn_byte_t op, pfx;
	if (opcode->got)
		return;
	if (!insn->prefixes.got)
		insn_get_prefixes(insn);

	/* Get first opcode */
	op = get_next(insn_byte_t, insn);
	opcode->bytes[0] = op;
	opcode->nbytes = 1;

	/* Check if there is VEX prefix or not */
	if (insn_is_avx(insn)) {
		insn_byte_t m, p;
		m = insn_vex_m_bits(insn);
		p = insn_vex_p_bits(insn);
		insn->attr = inat_get_avx_attribute(op, m, p);
		if (!inat_accept_vex(insn->attr))
			insn->attr = 0;	/* This instruction is bad */
		goto end;	/* VEX has only 1 byte for opcode */
	}

	insn->attr = inat_get_opcode_attribute(op);
	while (inat_is_escape(insn->attr)) {
		/* Get escaped opcode */
		op = get_next(insn_byte_t, insn);
		opcode->bytes[opcode->nbytes++] = op;
		pfx = insn_last_prefix(insn);
		insn->attr = inat_get_escape_attribute(op, pfx, insn->attr);
	}
	if (inat_must_vex(insn->attr))
		insn->attr = 0;	/* This instruction is bad */
end:
	opcode->got = 1;
}
示例#14
0
文件: adt.cpp 项目: yangjiao2/cs222
int PageDirectory::allocRecordPage(FileHandle &fh){
    int allocated = -1;
    while (get_pgnum() == PageDirectory::MaximunEntryNum() &&
           get_next() != 0)
        moveToNext(fh);
    
    char newrp[PAGE_SIZE], newpd_buffer[PAGE_SIZE];
    memset(newrp, 0, sizeof(newrp)); //all zeros is ok
    memset(newpd_buffer, 0, sizeof(newpd_buffer)); //all zeros is ok
    RecordPage rp(newrp);
    fh.appendPage(newrp);
    allocated = (int) (fh.getNumberOfPages() - 1);
    
    if (get_next() == 0 && get_pgnum() == PageDirectory::MaximunEntryNum()) {
        fh.appendPage(newpd_buffer);
        set_next(fh.getNumberOfPages() - 1);
        moveToNext(fh);
    }
    set_pgid(get_pgnum(), allocated);
    set_pgfreelen(get_pgnum(), rp.getFreelen());
    set_pgnum(get_pgnum() + 1);
    return allocated;
}
示例#15
0
void kfree_all_stainfo(struct sta_priv *pstapriv )
{
	_list	*plist, *phead;
	struct sta_info *psta = NULL;

_func_enter_;

	spin_lock_bh(&pstapriv->sta_hash_lock);

	phead = get_list_head(&pstapriv->free_sta_queue);
	plist = get_next(phead);

	while (phead != plist)
	{
		psta = LIST_CONTAINOR(plist, struct sta_info ,list);
		plist = get_next(plist);
	}

	spin_unlock_bh(&pstapriv->sta_hash_lock);

_func_exit_;

}
示例#16
0
static void some_really_long_function_name(struct device *dev, struct device_driver *drv)
{
   if ((some_variable_name && somefunction(param1, param2, param3)))
   {
      asdfghjk = asdfasdfasd.aasdfasd + (asdfasd.asdas * 1234.65);
   }

   for (struct something_really_really_excessive *a_long_ptr_name = get_first_item(); a_long_ptr_name != NULL; a_long_ptr_name = get_next_item(a_long_ptr_name))
   {
   }

   for (a = get_first(); a != NULL; a = get_next(a))
   {
   }

   for (a_ptr = get_first(); a_ptr != NULL; a_ptr = get_next(a))
   {
   }

 register_clcmd( "examine", "do_examine", -1, "-Allows a player to examine the health and armor of a teammate" );
       register_clcmd( "/examine", "do_examine", -1,
                      "-Allows a player to examine the health and armor of a teammate" );
}
示例#17
0
 bool try_pop(node_base*& node_to_free, node_base*& node_with_value)
 {
     exclusive_lock_guard< mutex_type > _(m_Head.mutex);
     node_base* next = get_next(m_Head.node);
     if (next)
     {
         // We have a node to pop
         node_to_free = m_Head.node;
         node_with_value = m_Head.node = next;
         return true;
     }
     else
         return false;
 }
示例#18
0
struct	wlan_network *r8712_get_oldest_wlan_network(
				struct  __queue *scanned_queue)
{
	struct list_head *plist, *phead;
	struct	wlan_network	*pwlan = NULL;
	struct	wlan_network	*oldest = NULL;

	phead = get_list_head(scanned_queue);
	plist = get_next(phead);
	while (1) {
		if (end_of_queue_search(phead, plist) ==  true)
			break;
		pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
		if (pwlan->fixed != true) {
			if (oldest == NULL ||
			    time_after((unsigned long)oldest->last_scanned,
			    (unsigned long)pwlan->last_scanned))
				oldest = pwlan;
		}
		plist = get_next(plist);
	}
	return oldest;
}
示例#19
0
// this function is used to free the memory of lock || sema for all stainfos
void rtw_mfree_all_stainfo(struct sta_priv *pstapriv )
{
	_irqL	 irqL;
	_list	*plist, *phead;
	struct sta_info *psta = NULL;



	SPIN_LOCK_BH(pstapriv->sta_hash_lock, &irqL);

	phead = get_list_head(&pstapriv->free_sta_queue);
	plist = get_next(phead);

	while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
	{
		psta = LIST_CONTAINOR(plist, struct sta_info ,list);
		plist = get_next(plist);

		rtw_mfree_stainfo(psta);
	}

	SPIN_UNLOCK_BH(pstapriv->sta_hash_lock, &irqL);
}
示例#20
0
u32 _rtw_free_sta_priv(struct	sta_priv *pstapriv)
{
	struct list_head	*phead, *plist;
	struct sta_info *psta = NULL;
	struct recv_reorder_ctrl *preorder_ctrl;
	int	index;

	if (pstapriv) {

		/*delete all reordering_ctrl_timer		*/
		spin_lock_bh(&pstapriv->sta_hash_lock);
		for (index = 0; index < NUM_STA; index++) {
			phead = &(pstapriv->sta_hash[index]);
			plist = get_next(phead);

			while (phead != plist) {
				int i;
				psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
				plist = get_next(plist);

				for (i = 0; i < 16 ; i++) {
					preorder_ctrl = &psta->recvreorder_ctrl[i];
					del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
				}
			}
		}
		spin_unlock_bh(&pstapriv->sta_hash_lock);
		/*===============================*/

		kfree_sta_priv_lock(pstapriv);

		if (pstapriv->pallocated_stainfo_buf)
			vfree(pstapriv->pallocated_stainfo_buf);

	}
	return _SUCCESS;
}
示例#21
0
/* Deze methode wijst length woorden toe aan een proces. De overgebleven
 * woorden worden gezien als nieuw vrij blok indien mogelijk, anders wordt de
 * overgebleven ruimte toegewezen aan het aanvragende proces. */
int split_block(long index, long length){
	long blockleng = get_length(index);
	long newidx = index + length + ADMIN_SIZE;
	long newleng = blockleng - length - ADMIN_SIZE;
	
	if(blockleng < length + ADMIN_SIZE + 1){
		/* Geen ruimte voor een nieuw blok van minimaal 1 woord. 
		 * Geef dus een blok ter groote van request + de resterende ruimte.
		 */
		length = blockleng;
	}else{
		/* Maak het nieuwe blok. Plaats deze na 'length' woorden. */
		new_block(newidx, newleng, index, get_next(index));
		
		/* Als het huidige blok een volgende blok heeft moet de pointer van
		 * dat blok welke naar zijn vorige blok wijst naar het nieuwe blok
		 * gezet worden.*/
		if(get_next(index) != 0){
			set_prev(get_next(index), newidx);
		}
		/* Zet het volgende blok van het huidige blok naar het nieuwe blok. */
		set_next(index, newidx);
	}
	
	/* Zet de length van het huidige blok en zet hem op toegewezen. */
	set_length(index, length);
	set_free(index, 0);
	
	/* Verhoog het aantal loze woorden. */
	mem[1] += ADMIN_SIZE;
	/* Verhoog het aantal toegewezen woorden. */
	mem[0] += length;
	
	/* De index waar begonnen mag worden met schrijven is het blok index
	 * plus de lengte van de administratie. */
	return index + ADMIN_SIZE;
}
示例#22
0
int main()

{
	int n,n_common,n2;

	char s[20] = "adjfskjfskdjsfkglsi";

	char t[5] = "skdj";
	
	PSString ps, pt;
	//(1)
	create(s, ps);		

	create(t, pt);

	//(2)
	n_common = index_common(ps, pt);

	int next[Maxsize],nextval[Maxsize];


	printf("普通匹配情况下:\n");
	print_result(n_common);
	//(3)
	get_next(pt, next);

	
	
	
	//(4)
	n = index_KMP(ps, pt, next);
	
	printf("\n\nKMP匹配情况下:\n");
	
	print_result(n);
	
	for (int i = 0; i < 5; i++)
		printf("next[%d] = %d \n", i, next[i]);
	//(5)
	n2 = index_KMP2(ps, pt, nextval);

	printf("\n\nKMP修正版匹配情况下:\n");
	
	print_result(n2);

	for (int i = 0; i < 5; i++)
		printf("nextval[%d] = %d \n", i, nextval[i]);
	return 0;
}
void Grammar::pseudo_non_terminals() {
	auto current = get_first(unite(non_terminals, terminals), 'Q');
	SymbolList temp_non_terms = non_terminals;
	SymbolList pseudo_non_terms;
	unsigned int c = 0;
	for( auto T : terminals ) {
		SymbolList temp;
		temp.push_back(T);
		non_terminals.push_back(current);
		pseudo_non_terms.push_back(current);
		production_rules[get_nt_index(current)].push_back(temp);
		//std::cout << current << " " << production_rules[get_nt_index(current)].back() << " " << production_rules[get_nt_index(current)].size() << '\n';
		get_next(current, ++c);
	}

	for( auto nT : temp_non_terms ) {
		std::vector<SymbolList> temp_rules;
		for( auto rule : production_rules[get_nt_index(nT)] ) {
			//std::cout << "rule: " << rule << " => ";
			if( rule.size() == 1 ) {
				//std::cout << "unchanged\n";
				temp_rules.push_back(rule);
				continue;
			}
			for( auto ch : rule ) {
				//std::cout << "ch: " << ch << '\n';
				if( contains_char(terminals, ch) ) {
					unsigned int i = pseudo_non_terms.size();
					while( i --> 0 ) {
						//std::cout << "while( "<<i<<" --> 0)\n";
						auto x = production_rules[get_nt_index(pseudo_non_terms[i])];
						//std::cout << production_rules[get_nt_index(pseudo_non_terms[i])][0];
						//std::cout << x[0][0] << " =?= " << ch << '\n';
						if( ch == x[0][0] ) {
							//std::cout << " :: TRUE\n";
							break;
						}
					}
					auto t = pseudo_non_terms[i];
					replace_first_of(rule, ch, t);
				}
			}
			//std::cout << rule << '\n';
			temp_rules.push_back(rule);
		}
		production_rules[get_nt_index(nT)] = temp_rules;
	}

}
示例#24
0
文件: zpios_main.c 项目: Alyseo/zfs
static int
run_offsets(cmd_args_t *args)
{
	int rc = 0;

	while (rc == 0 && get_next(&args->current_O, &args->O)) {
		rc = run_one(args, args->current_id,
		    args->current_T, args->current_N, args->current_C,
		    args->current_S, args->current_O, args->current_B);
		args->current_id++;
	}

	args->O.next_val = 0;
	return (rc);
}
compressed_file_reader::compressed_file_reader(const mmap_file& file,
                                               std::function
                                               <uint64_t(uint64_t)> mapping)
    : file_{nullptr},
      start_{file.begin()},
      size_{file.size()},
      status_{notDone},
      current_value_{0},
      current_char_{0},
      current_bit_{0},
      mapping_{std::move(mapping)}
{
    // initialize the stream
    get_next();
}
uint64_t compressed_file_reader::next()
{
    if (status_ == userDone)
        return 0;

    if (status_ == readerDone)
    {
        status_ = userDone;
        return current_value_;
    }

    uint64_t next = mapping_(current_value_);
    get_next();
    return next;
}
示例#27
0
文件: llist.c 项目: kilogram/SLAM
int append(lnode *head, void *data)
   // USAGE: int a; append(head, &a);
   // Insert a node at the tail of the linked list.
{
   if (!head) return LLIST_INVALID_HEAD;
   if (!data) fprintf(stderr, "Warning: null data pointer.");
   lnode *last = &(*head);
   while(get_next(last, &last) == 0);
   lnode *add = malloc(LNODEP_SIZE);
   if (!add) return LLIST_MALLOC_ERROR;
   add->data = data;
   add->next = NULL;
   last->next = add;
   return LLIST_NO_ERR;
}
示例#28
0
文件: 1686.cpp 项目: cpsa3/backup
void get_ans()
{
	get_next();
	int i,p=0;
	for(i=1;i<=lens;i++)
	{
		while(p>0&&T[p+1]!=S[i])
			p=next[p];
		if(T[p+1]==S[i])
			p++;
		if(p==lent)
		{ans++;p=next[p];}
	}
	printf("%d\n",ans);
}
示例#29
0
u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
{
	bool res = true;
	struct list_head	*plist, *phead;
	struct rtw_wlan_acl_node *paclnode;
	bool match = false;
	struct sta_priv *pstapriv = &padapter->stapriv;
	struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
	struct __queue	*pacl_node_q = &pacl_list->acl_node_q;

	spin_lock_bh(&(pacl_node_q->lock));
	phead = get_list_head(pacl_node_q);
	plist = get_next(phead);
	while (phead != plist) {
		paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list);
		plist = get_next(plist);

		if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN))
			if (paclnode->valid == true) {
				match = true;
				break;
			}

	}
	spin_unlock_bh(&(pacl_node_q->lock));

	if (pacl_list->mode == 1) /* accept unless in deny list */
		res = !match;

	else if (pacl_list->mode == 2)/* deny unless in accept list */
		res = match;
	else
		 res = true;

	return res;
}
示例#30
0
 int strStr(string haystack, string needle) {
     int n = haystack.length(),m = needle.length();
     if(!m) return 0;
     int next[m+1],i = 0,j = 0;
     get_next(needle,next);
     while(i < n){
         if(haystack[i]==needle[j]){
             ++i,++j;
             if(j == m) return i-m;
         }
         else if(j) j = next[j-1];
         else ++i;
     }
     return -1;
 }