Ejemplo n.º 1
0
static void font_box_put_item (
char **item,							/* Pointer to the pointer to the	*/
										/* item to insert (C is great)		*/
										/* RETURNED							*/
int *number,							/* Pointer to the number of items	*/
										/* RETURNED							*/
char ***menu_list)						/* Pointer to the pointer to the	*/
										/* array of items (C is $%*!@#)		*/
{
	int i, j;

/* Do nothing if the item is undefined */
	if (NULL == *item) return;

/* Search an item equal to the one to insert in the list */
	for (i = 0; (i < *number) && (strcmp ((*menu_list) [i], *item)); i++);

/* If found, modify the pointer to the item */
	if (i < *number) {
		eif_rt_xfree (*item);
		*item = (*menu_list) [i];
		return;
	}

/* If not insert it into the list */
	if ((*number)++) *menu_list = (char **) crealloc (*menu_list, (*number)*sizeof (char *));
	else *menu_list = (char **) cmalloc (sizeof (char *));
	(*menu_list) [i] = *item;
}
Ejemplo n.º 2
0
static void font_box_destroy_action (
Widget widget,							/* useless							*/
font_box_data * client,					/* font-box datas					*/
XtPointer motif)						/* Useless							*/
{
	eif_rt_xfree (client);
} /* font_box_destroy_action */
Ejemplo n.º 3
0
/*
doc:	<routine name="ht_free" export="shared">
doc:		<summary>Free memory used internally by `ht' and `ht' itself assuming it was allocated by the runtime memory routines (i.e. not `eif_malloc' or `eif_calloc'.</summary>
doc:		<param name="ht" type="struct htable *">Table to initialize.</param>
doc:		<thread_safety>Not Safe</thread_safety>
doc:		<synchronization>None</synchronization>
doc:	</routine>
*/
rt_shared void ht_free(struct htable *ht)
{
	REQUIRE("ht not null", ht);

		/* Free hash table arrays and descriptor */
	ht_release (ht);
	eif_rt_xfree((char *) ht);
}
Ejemplo n.º 4
0
void set_fallback_res (EIF_POINTER w, EIF_OBJ res, EIF_INTEGER count)
{
	int counter = 0;

	if (fallback_list != (String *) 0) {
		String * temp = fallback_list;
		while (temp) eif_rt_xfree (*(temp++));
		eif_rt_xfree (fallback_list);
		fallback_list = (String *) 0;
	}
	if (res != (EIF_OBJ) 0) {
		fallback_list = (String *) cmalloc (count * sizeof (String) + 1);
		while (count > counter) {
			*(fallback_list + counter) = (String) cmalloc (strlen (*((char **)eif_access(res) + counter)) + 1);
			strcpy (*(fallback_list + counter), *((char **)(eif_access (res)) + counter));
			counter++;
		}
		*(fallback_list + counter) = (String) 0;
	}
		
	XtAppSetFallbackResources ((XtAppContext) w, fallback_list);
}
Ejemplo n.º 5
0
rt_public void eif_free_call (call_data * a)
{
	EIF_NATURAL_32    i;
	EIF_TYPED_VALUE * v;

		/* Unprotect arguments from being garbage-collected. */
	for (i = a -> count; i > 0;) {
		v = &(a -> argument [--i]);
		if ((v -> it_r) && (v -> type & SK_HEAD) == SK_REF) {
			eif_unsafe_wean ((EIF_OBJECT) v -> it_r);
		}
	}
		/* Unprotect target of a call. */
	eif_unsafe_wean (a -> target);
		/* Free memory, allocated for `a'. */
	eif_rt_xfree (a);
}
Ejemplo n.º 6
0
void c_free_xpoints (EIF_POINTER array)
{
	eif_rt_xfree ((XPoint *) array);
}
Ejemplo n.º 7
0
rt_public EIF_BOOLEAN spiso(register EIF_REFERENCE target, register EIF_REFERENCE source)
{
	/* Compare two special objects in term of their structures. `source'
	 * and `target' are refering two special objects. There is three cases:
	 * 1- either the elements are direct instances: block comparison.
	 * 2- either the elements are references: comparison of referenced
	 *	dynamic type.
	 * 3- or the elements are expanded: call `eiso' (special objects
	 *	cannot be expanded).
	 */

	union overhead *s_zone;				/* Source header */
	uint32 s_flags;						/* Source flags */
	/*uint32 t_flags;*/					/* Target flags */
	EIF_REFERENCE s_ref;
	EIF_REFERENCE t_ref;
	EIF_INTEGER count;				/* Common count */
	EIF_INTEGER elem_size;			/* Common element size */
	EIF_REFERENCE s_field, t_field;

	REQUIRE("special objects", (HEADER(target)->ov_flags & EO_SPEC) && (HEADER(source)->ov_flags & EO_SPEC));

	if (source == target)
		return EIF_TRUE;

	s_zone = HEADER(source);

#ifdef DEBUG
	dprintf(2)("spiso: source = 0x%lx [%d] target = 0x%lx [%d]\n",
		source, RT_SPECIAL_COUNT(source),
		target, RT_SPECIAL_COUNT(target));
#endif

	count = RT_SPECIAL_COUNT(source);
	if (count != RT_SPECIAL_COUNT(target))
		return EIF_FALSE;

	/* Second condition: same element size */
	elem_size = RT_SPECIAL_ELEM_SIZE(source);
	if (elem_size != RT_SPECIAL_ELEM_SIZE(target))
		return EIF_FALSE;

	s_flags = s_zone->ov_flags;

		/* In final mode, we can do block comparison on special of basic types
		 * or on special of expanded which have no references since they have no header.
		 * In workbench mode, block comparison is only possible on special of basic types. */
#ifdef WORKBENCH
	if (!(s_flags & EO_REF) && !(s_flags & EO_COMP)) {
#else
	if (!(s_flags & EO_REF)) {
#endif
		/* Case 1: specials filled with direct instances: block comparison */
		return EIF_TEST(!memcmp (source, target, (rt_uint_ptr) count * (rt_uint_ptr) elem_size));
	}

	if (s_flags & EO_TUPLE) {
		EIF_TYPED_VALUE * l_source = (EIF_TYPED_VALUE *) source;
		EIF_TYPED_VALUE * l_target = (EIF_TYPED_VALUE *) target;
			/* Don't forget that first element of TUPLE is the BOOLEAN
			 * `object_comparison' attribute. */
		for (; count > 0; count--, l_source++, l_target++) {
			if
				(eif_is_reference_tuple_item(l_source) &&
				eif_is_reference_tuple_item(l_target))
			{
				s_field = eif_reference_tuple_item (l_source);
				t_field = eif_reference_tuple_item (l_target);
				if ((s_field == NULL) && (t_field == NULL)) {
					continue;
				} else if ((s_field) && (t_field) && (Dtype(s_field) == Dtype(t_field))) {
					continue;
				} else {
					return EIF_FALSE;
				}
			}
		}
		return EIF_TRUE;
	} else if ((s_flags & EO_REF) && !(s_flags & EO_COMP)) {
		/* Case 2: specials filled with references: we have to check fields
		 * one by one.
		 */
		for(
			s_ref = (EIF_REFERENCE)source, t_ref = (EIF_REFERENCE) target;
			count > 0;
			count --,
				s_ref = (EIF_REFERENCE) ((EIF_REFERENCE *) s_ref + 1),
				t_ref = (EIF_REFERENCE) ((EIF_REFERENCE *) t_ref + 1)
		) {
			/* Evaluation of two references */
			s_field = *(EIF_REFERENCE *) s_ref;
			t_field = *(EIF_REFERENCE *) t_ref;
			if ((!s_field) && (!t_field))
				/* Two void references */
				continue;
			else if (		(((EIF_REFERENCE) 0) != s_field) &&
							(((EIF_REFERENCE) 0) != t_field) &&
							(Dtype(s_field) == Dtype(t_field))
					)
				/* Two non-void references on objects of same dynamic type */
				continue;
			else
				/* No ismorphism */
				return EIF_FALSE;
		}
		return EIF_TRUE;
	}

	/* Case 3: special objects filled with (non-special) expanded objects.
	 * we call then standard isomorphism test on normal objects.
	 */
	for (
		s_ref = source +OVERHEAD, t_ref = target+OVERHEAD;
		count >0;
		count--, s_ref += elem_size, t_ref += elem_size
	) {
		/* Iteration on expanded elements */
		if (!eiso(t_ref, s_ref))
			return EIF_FALSE;
	}

	return EIF_TRUE;
}

rt_public EIF_BOOLEAN ediso(EIF_REFERENCE target, EIF_REFERENCE source)
{
	/* Compare recursively the structure attached to `target' to the
	 * one attached to `source'. This is the standard Eiffel feature
	 * because it called recursively the standard isomorhic Eiffel
	 * feature.
	 * Return a boolean.
	 */

	RT_GET_CONTEXT
	EIF_BOOLEAN result;
#ifdef ISE_GC
	char g_status;		/* Save GC status */

	g_status = eif_gc_ison();
	if (g_status)
		eif_gc_stop();						/* Stop GC if enabled*/
#endif

	eif_equality_table = s_create(100);				/* Create search table */
	result = rdeepiso(target,source);	/* Recursive isomorphism test */

#ifdef ISE_GC
	if (g_status)
		eif_gc_run();						/* Enabled GC it was previously enabled */
#endif

	eif_rt_xfree((EIF_REFERENCE) (eif_equality_table->s_keys));	/* Free search table keys */
	eif_rt_xfree((EIF_REFERENCE) eif_equality_table);			/* Free search table descriptor */
	eif_equality_table = NULL;
	return result;
}