static struct ldb_parse_tree *make_match_tree(struct ldb_module *module,
					      TALLOC_CTX *mem_ctx,
					      enum ldb_parse_op op,
					      const char *attr,
					      struct ldb_val *match)
{
	struct ldb_context *ldb;
	struct ldb_parse_tree *match_tree;

	ldb = ldb_module_get_ctx(module);

	match_tree = talloc(mem_ctx, struct ldb_parse_tree);
	
	/* Depending on what type of match was selected, fill in the right part of the union */
	 
	match_tree->operation = op;
	switch (op) {
	case LDB_OP_SUBSTRING:
		match_tree->u.substring.attr = attr;
		
		match_tree->u.substring.start_with_wildcard = 0;
		match_tree->u.substring.end_with_wildcard = 1;
		match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2);
		
		if (match_tree->u.substring.chunks == NULL){
			talloc_free(match_tree);
			ldb_oom(ldb);
			return NULL;
		}
		match_tree->u.substring.chunks[0] = match;
		match_tree->u.substring.chunks[1] = NULL;
		break;
	case LDB_OP_EQUALITY:
		match_tree->u.equality.attr = attr;
		match_tree->u.equality.value = *match;
		break;
	default:
		talloc_free(match_tree);
		return NULL;
	}
	return match_tree;
}
static struct ldb_parse_tree *make_match_tree(struct ldb_module *module,
					      TALLOC_CTX *mem_ctx,
					      enum ldb_parse_op op,
					      const char *attr,
					      struct ldb_val *match)
{
	struct ldb_context *ldb;
	struct ldb_parse_tree *match_tree;

	ldb = ldb_module_get_ctx(module);

	match_tree = talloc(mem_ctx, struct ldb_parse_tree);
	
	 
	 
	match_tree->operation = op;
	switch (op) {
	case LDB_OP_SUBSTRING:
		match_tree->u.substring.attr = attr;
		
		match_tree->u.substring.start_with_wildcard = 0;
		match_tree->u.substring.end_with_wildcard = 1;
		match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2);
		
		if (match_tree->u.substring.chunks == NULL){
			talloc_free(match_tree);
			ldb_oom(ldb);
			return NULL;
		}
		match_tree->u.substring.chunks[0] = match;
		match_tree->u.substring.chunks[1] = NULL;
		break;
	case LDB_OP_EQUALITY:
		match_tree->u.equality.attr = attr;
		match_tree->u.equality.value = *match;
		break;
	default:
		talloc_free(match_tree);
		return NULL;
	}
	return match_tree;
}