static int map_init_maps(struct ldb_module *module, struct ldb_map_context *data, 
			 const struct ldb_map_attribute *attrs, 
			 const struct ldb_map_objectclass *ocls, 
			 const char * const *wildcard_attributes)
{
	unsigned int i, j, last;
	last = 0;

	/* Count specified attribute maps */
	for (i = 0; attrs[i].local_name; i++) /* noop */ ;
	/* Count built-in attribute maps */
	for (j = 0; builtin_attribute_maps[j].local_name; j++) /* noop */ ;

	/* Store list of attribute maps */
	data->attribute_maps = talloc_array(data, struct ldb_map_attribute, i+j+2);
	if (data->attribute_maps == NULL) {
		map_oom(module);
		return LDB_ERR_OPERATIONS_ERROR;
	}

	/* Specified ones go first */
	for (i = 0; attrs[i].local_name; i++) {
		data->attribute_maps[last] = attrs[i];
		last++;
	}

	/* Built-in ones go last */
	for (i = 0; builtin_attribute_maps[i].local_name; i++) {
		data->attribute_maps[last] = builtin_attribute_maps[i];
		last++;
	}

	if (data->add_objectclass) {
		/* ObjectClass one is very last, if required */
		data->attribute_maps[last] = objectclass_attribute_map;
		last++;
	} else if (ocls) {
		data->attribute_maps[last] = objectclass_convert_map;
		last++;
	}

	/* Ensure 'local_name == NULL' for the last entry */
	memset(&data->attribute_maps[last], 0, sizeof(struct ldb_map_attribute));

	/* Store list of objectClass maps */
	data->objectclass_maps = ocls;

	data->wildcard_attributes = wildcard_attributes;

	return LDB_SUCCESS;
}
static int map_init_maps(struct ldb_module *module, struct ldb_map_context *data, 
			 const struct ldb_map_attribute *attrs, 
			 const struct ldb_map_objectclass *ocls, 
			 const char * const *wildcard_attributes)
{
	unsigned int i, j, last;
	last = 0;

	 
	for (i = 0; attrs[i].local_name; i++)   ;
	 
	for (j = 0; builtin_attribute_maps[j].local_name; j++)   ;

	 
	data->attribute_maps = talloc_array(data, struct ldb_map_attribute, i+j+2);
	if (data->attribute_maps == NULL) {
		map_oom(module);
		return LDB_ERR_OPERATIONS_ERROR;
	}

	 
	for (i = 0; attrs[i].local_name; i++) {
		data->attribute_maps[last] = attrs[i];
		last++;
	}

	 
	for (i = 0; builtin_attribute_maps[i].local_name; i++) {
		data->attribute_maps[last] = builtin_attribute_maps[i];
		last++;
	}

	if (data->add_objectclass) {
		 
		data->attribute_maps[last] = objectclass_attribute_map;
		last++;
	} else if (ocls) {
		data->attribute_maps[last] = objectclass_convert_map;
		last++;
	}

	 
	memset(&data->attribute_maps[last], 0, sizeof(struct ldb_map_attribute));

	 
	data->objectclass_maps = ocls;

	data->wildcard_attributes = wildcard_attributes;

	return LDB_SUCCESS;
}