Exemple #1
0
/*
 * Try to free modules which have been marked for deletion.  Returns nonzero
 * if a module was actually freed.
 */
int
free_modules( void)
{
	struct module *mp;
	struct module **mpp;
	int did_deletion;

	did_deletion = 0;
	freeing_modules = 0;
	mpp = &module_list;
	while ((mp = *mpp) != NULL) {
		if (mp->state != MOD_DELETED) {
			mpp = &mp->next;
		} else {
			if ((GET_USE_COUNT(mp) != 0) || (mp->ref != NULL)) {
				freeing_modules = 1;
				mpp = &mp->next;
			} else {	/* delete it */
				*mpp = mp->next;
				if (mp->symtab) {
					if (mp->symtab->n_refs)
						drop_refs(mp);
					if (mp->symtab->size)
						kfree_s(mp->symtab, mp->symtab->size);
				}
				vfree(mp->addr);
				kfree_s(mp, sizeof(struct module) + MOD_MAX_NAME);
				did_deletion = 1;
			}
		}
	}
	return did_deletion;
}
	void	as_value::set_as_object(as_object* obj)
	{
		if (m_type != OBJECT || m_object != obj)
		{
			drop_refs();
			m_type = OBJECT;
			m_object = obj;
		}
	}
	void	as_value::operator=(const as_value& v)
	{
		switch (v.m_type)
		{
			case UNDEFINED:
				set_undefined();
				break;

			case NUMBER:
				set_double(v.m_number);
				m_flags = v.m_flags;
				break;

			case BOOLEAN:
				set_bool(v.m_bool);
				m_flags = v.m_flags;
				break;

			case STRING:
				set_tu_string(v.m_string);
				m_flags = v.m_flags;
				break;

			case OBJECT:
				set_as_object(v.m_object);
				m_flags = v.m_flags;
				break;

			case PROPERTY:
				drop_refs(); 
				
				// is binded property ?
				if (v.m_property_target == NULL)
				{
					m_type = PROPERTY;
					m_property = v.m_property;
					m_property_target = NULL;
				}
				else
				{
					v.get_property(this);
				}
				m_flags = v.m_flags;

				break;

			default:
				assert(0);
		}
	}
	void	as_value::set_string(const char* str)
	{
		drop_refs();
		m_type = STRING;
		m_string = str; 
	}
	void	as_value::set_tu_string(const tu_string& str)
	{
		drop_refs();
		m_type = STRING;
		m_string = str; 
	}
	void	as_value::set_bool(bool val)
	{
		drop_refs();
		m_type = BOOLEAN;
		m_bool = val;
	}
	void	as_value::set_double(double val)
	{
		drop_refs();
		m_type = NUMBER;
		m_number = val;
	}