base/list/m_list.c
/* dest will be created if *dest == NULL. src will be freed. Any values within
 * src that are not moved to dest will be freed.
 */
dest will be created if *dest == NULL. src will be freed. Any values within
src that are not moved to dest will be freed.
dest will be created if * dest == NULL . src will be freed . Any values within src that are not moved to dest will be freed .
static void M_list_merge_int(M_list_t **dest, M_list_t *src, M_list_t *dups, M_bool include_duplicates, M_uint32 type)
{
	void                    *val;
	size_t                   i;
	struct M_list_callbacks  callbacks;
	if (src == NULL) {
		return;
	}
	if ((*dest == NULL || M_list_len(*dest) == 0) && dups == NULL) {
		M_list_destroy(*dest, M_TRUE);
		*dest = src;
		return;
	}
	if (*dest == NULL) {
		callbacks.equality         = src->equality;
		callbacks.duplicate_insert = src->duplicate_insert;
		callbacks.duplicate_copy   = src->duplicate_copy;
		callbacks.value_free       = src->value_free;
		*dest = M_list_create(&callbacks, src->flags);
	}
	if ((*dest)->flags & (M_LIST_SET_VAL|M_LIST_SET_PTR)) {
		include_duplicates = M_FALSE;
		type               = ((*dest)->flags&M_LIST_SET_PTR)?M_LIST_MATCH_PTR:M_LIST_MATCH_VAL;
	}
	M_list_insert_begin(*dest);
	for (i=0; i<src->elements; i++) {
		val = src->start[i];
		if (!include_duplicates && dups != NULL) {
			if (M_list_index_of(dups, val, type, NULL)) {
				src->value_free(val);
				continue;
			}
		}
		M_list_insert_at_int(*dest, val, (*dest)->elements, M_LIST_INSERT_NODUP|M_LIST_INSERT_NOSETCHECK);
	}
	M_list_insert_end(*dest);
	M_list_destroy(src, M_FALSE);
}
static void M_list_merge_int ( M_list_t * * dest , M_list_t * src , M_list_t * dups , M_bool include_duplicates , M_uint32 type ) { void * val ; size_t i ; struct M_list_callbacks callbacks ; if ( src == NULL ) { return ; } if ( ( * dest == NULL || M_list_len ( * dest ) == 0 ) && dups == NULL ) { M_list_destroy ( * dest , M_TRUE ) ; * dest = src ; return ; } if ( * dest == NULL ) { callbacks . equality = src -> equality ; callbacks . duplicate_insert = src -> duplicate_insert ; callbacks . duplicate_copy = src -> duplicate_copy ; callbacks . value_free = src -> value_free ; * dest = M_list_create ( & callbacks , src -> flags ) ; } if ( ( * dest ) -> flags & ( M_LIST_SET_VAL | M_LIST_SET_PTR ) ) { include_duplicates = M_FALSE ; type = ( ( * dest ) -> flags & M_LIST_SET_PTR ) ? M_LIST_MATCH_PTR : M_LIST_MATCH_VAL ; } M_list_insert_begin ( * dest ) ; for ( i = 0 ; i < src -> elements ; i ++ ) { val = src -> start [ i ] ; if ( ! include_duplicates && dups != NULL ) { if ( M_list_index_of ( dups , val , type , NULL ) ) { src -> value_free ( val ) ; continue ; } } M_list_insert_at_int ( * dest , val , ( * dest ) -> elements , M_LIST_INSERT_NODUP | M_LIST_INSERT_NOSETCHECK ) ; } M_list_insert_end ( * dest ) ; M_list_destroy ( src , M_FALSE ) ; }
dest will be created if *dest == NULL.
dest will be created if * dest == NULL .
/* If dest is a set we're never going to include duplicates. */