Пример #1
0
nyx_error_t nyx_device_close(nyx_device_handle_t handle)
{
	nyx_device_t* d = (nyx_device_t*)handle;

	CHECK_DEVICE(d);

	/*
	 * we need to cache method hash table as it might be
	 * used during the close, we will destroy it after
	 * a call to close.
	 */
	GHashTable* method_hash_table = (GHashTable*)d->method_hash_table;
	char* name = d->name;
	char* desc = d->description;

	/*
	 * Don't know if necessary but since we are deallocating
	 * the device structure during the call to close method
	 * let's first cache the pointer to close method.
	 */
	void* module_ptr = d->module_ptr;
	nyx_close_function_t close_ptr = d->close_ptr;
	nyx_error_t error = close_ptr(d);

	/*
	 * let's destroy the method hash table.
	 */
	if (method_hash_table)
		g_hash_table_destroy (method_hash_table);
	if (name)
		free (name);
	if (desc)
		free (desc);

	/*
	 * We are done so, we can close the module.
	 */
	dlclose(module_ptr);


	return error;
}
Пример #2
0
void close_with_time(int* dest, git_time_t timestamp) {
	UTIME_THINGY(futimens(*dest,times));
	close_ptr(dest);
}