Exemple #1
0
ClcCacheEntry *GetCLCFullCacheEntry(struct ClcData *dat,MCONTACT hContact)
{
	if (hContact == 0)
		return NULL;

	ClcCacheEntry dnce;
	dnce.hContact = hContact;
	ClcCacheEntry *pdnce = (ClcCacheEntry*)List_Find(&dat->lCLCContactsCache,&dnce);
	if (pdnce == NULL) {
		pdnce = (ClcCacheEntry*)mir_calloc(sizeof(ClcCacheEntry));
		pdnce->hContact = hContact;

		int idx;
		List_GetIndex(&dat->lCLCContactsCache,pdnce,&idx);
		List_Insert(&dat->lCLCContactsCache,pdnce,idx);

		ClcCacheEntry *pdnce2 = (ClcCacheEntry*)List_Find(&dat->lCLCContactsCache,&dnce);//for check
		if (pdnce2->hContact != pdnce->hContact)
			return NULL;

		if (pdnce2 != pdnce)
			return NULL;
	}

	return (pdnce);
}
Exemple #2
0
BOOL List_Remove(List * pList,
                 PVOID pData)
{
	Node * node = List_Find(pList, pData);
	BOOL removed = FALSE;
	if (node) { List_RemoveNode(pList, node); removed = TRUE; }
	return removed;
}
Exemple #3
0
SO_PUBLIC struct Thread *
Thread_GetCurrent(void) {
	struct Thread *l_pRet = NULL;
	rzb_thread_t l_tCurrent = Thread_GetCurrentId();
	l_pRet = (struct Thread *)List_Find(sg_threadList, &l_tCurrent);
	if (l_pRet == NULL)
		return NULL;

	Thread_Lock(l_pRet);
	l_pRet->refs++;
	Thread_Unlock(l_pRet);
	return l_pRet;
}
void
FreeFileDescriptor(uint64_t fd){

	if(fd >= fd_base)
		return;

	uint64_t index = List_Find(fds, finder, (void*)fd);
	if(index == -1)
		return;

	FileDescriptor *f_desc = List_EntryAt(fds, index);
	List_Remove(fds, index);
	free(f_desc);

	return;
}
bool
GetFileDescriptor(uint64_t fd, int *flags, int *mode, uint64_t *hash, FileSystemObject **a) {

	if(fd > fd_base)
		return false;

	uint64_t index = List_Find(fds, finder, (void*)fd);
	if(index == -1)
		return false;

	FileDescriptor *f_desc = List_EntryAt(fds, index);

	if(flags != NULL)*flags = f_desc->flags;
	if(mode != NULL)*mode = f_desc->mode;
	if(hash != NULL)*hash = f_desc->hash;
	if(a != NULL)*a = f_desc->obj;

	return true;
}