コード例 #1
0
HRESULT crAddCallback(CALLBACK_DESCRIPTOR* callback)
{
	HRESULT		hResult = NO_ERROR;

	// First check for required key types, these are described in the cr.h
	hResult = kvIsKey(callback, CALLBACK_DESCRIPTOR_TYPE);
	if (hResult != NO_ERROR) return hResult;
	
	hResult = kvIsKey(callback, CALLBACK_DESCRIPTOR_NEXT);
	if (hResult != NO_ERROR) return hResult;
	
#ifdef _SYSDEBUG
	// check in debug mode never to allow adding of the same element twice
	if (crFindCallback(CR_FIND_CALLBACK_THIS, 0, 0, callback, &callback) == TRUE)
	{
		char*	name = NULL;
		kvGetValue(callback, CALLBACK_DESCRIPTOR_NAME, (uint32*) &name);
		sysDebugPrintf("cr error: can't add callback '%s'(0x%08X) twice\n\r", (name) ? name : "un-named", callback);
	}
#endif //_SYSDEBUG
	
	// exclusive access for the cr list (mutex)
	hResult = TCMutexLock(crListMutexSemID);
	if (hResult != NO_ERROR) return hResult;
	
	// need to link this descriptor into the list, by making the crDescHead the next element, and making this the crDescHead
	kvSetValue(callback, CALLBACK_DESCRIPTOR_NEXT, (uint32) crDescHead);
	crDescHead = callback;
	
	// exclusive access for the cr list (mutex)
	TCMutexUnlock(crListMutexSemID);

	return hResult;
}
コード例 #2
0
void kvFreeKey(KEYVALUE* list, uint32 key)
{
	HRESULT		hResult = NO_ERROR;
	uint32		curkey, curvalue;
	
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return;
	}

	hResult = kvIsKey(list, key);
	if (hResult != NO_ERROR) return;

	DO_FOREVER
	{
		curkey = list->key;
		curvalue = list->value;
		
		if (curkey == KV_TERMINATEKEY || curvalue == KV_TERMINATEVALUE) break;

		if (curkey == key)
		{
			list->key = KV_KEYSPACE;
			break;
		}

		list++;
	}
}