rem: dprintf(":: compare: \"%s\" <-> \"%s\" (%ld)\n", iterator->prefix, sBuiltInModules[i]->name, iterator->prefix_length);
context: iterator_get_next_module(module_iterator *iterator, char *buffer, size_t *_bufferSize){	status_t status;	TRACE(("iterator_get_next_module() -- start\n"));	if (iterator->builtin_modules) {		int32 i;		for (i = iterator->module_offset; sBuiltInModules[i] != NULL; i++) {			// the module name must fit the prefixdprintf(":: compare: \"%s\" <-> \"%s\" (%ld)\n", iterator->prefix, sBuiltInModules[i]->name, iterator->prefix_length);			if (strncmp(sBuiltInModules[i]->name, iterator->prefix, iterator->prefix_length))				continue;			*_bufferSize = strlcpy(buffer, sBuiltInModules[i]->name, *_bufferSize);			iterator->module_offset = i + 1;			return B_OK;		}		iterator->builtin_modules = false;	}nextPath:	if (iterator->current_dir == NULL) {		// get next directory path from the stack		const char *path = iterator_pop_path_from_stack(iterator, &iterator->path_base_length);		if (path == NULL) {			// we are finished, there are no more entries on the stack			return B_ENTRY_NOT_FOUND;		}		free((void *)iterator->current_path);		iterator->current_path = path;		iterator->current_dir = opendir(path);		TRACE(("open directory at %s -> %p\n", path, iterator->current_dir));		if (iterator->current_dir == NULL) {			// we don't throw an error here, but silently go to			// the next directory on the stack			goto nextPath;		}	}nextModuleImage:	if (iterator->current_header == NULL) {		// get next entry from the current directory		char path[B_PATH_NAME_LENGTH];		struct dirent *dirent;		struct stat st;		int32 passedOffset, commonLength;		errno = 0;		if ((dirent = readdir(iterator->current_dir)) == NULL) {			closedir(iterator->current_dir);			iterator->current_dir = NULL;			if (errno < B_OK)				return errno;			goto nextPath;		}		// check if the prefix matches		passedOffset = strlen(iterator->current_path) + 1;		commonLength = iterator->path_base_length + iterator->prefix_length - passedOffset;		if (commonLength > 0) {			// the prefix still reaches into the new path part			int32 length = strlen(dirent->d_name);			if (commonLength > length)				commonLength = length;			if (strncmp(dirent->d_name,					iterator->prefix + passedOffset - iterator->path_base_length, commonLength))				goto nextModuleImage;		}		// we're not interested in traversing these again		if (!strcmp(dirent->d_name, ".")			|| !strcmp(dirent->d_name, ".."))			goto nextModuleImage;		// build absolute path to current file		strlcpy(path, iterator->current_path, sizeof(path));		strlcat(path, "/", sizeof(path));		strlcat(path, dirent->d_name, sizeof(path));		// find out if it's a directory or a file		if (stat(path, &st) < 0)			return errno;		iterator->current_module_path = strdup(path);		if (iterator->current_module_path == NULL)			return B_NO_MEMORY;		if (S_ISDIR(st.st_mode)) {			status = iterator_push_path_on_stack(iterator, iterator->current_module_path,							iterator->path_base_length);			if (status < B_OK)				return status;			iterator->current_module_path = NULL;			goto nextModuleImage;		}		if (!S_ISREG(st.st_mode))			return B_BAD_TYPE;		TRACE(("open module at %s\n", path));		status = get_module_image(path, &iterator->module_image);		if (status < B_OK) {			free((void *)iterator->current_module_path);			iterator->current_module_path = NULL;			goto nextModuleImage;		}		iterator->current_header = iterator->module_image->info;		iterator->module_offset = 0;	}	// search the current module image until we've got a match	while (*iterator->current_header != NULL) {		module_info *info = *iterator->current_header;		// ToDo: we might want to create a module here and cache it in the hash table		iterator->current_header++;		iterator->module_offset++;		if (strncmp(info->name, iterator->prefix, iterator->prefix_length))			continue;		*_bufferSize = strlcpy(buffer, info->name, *_bufferSize);		return B_OK;	}	// leave this module and get the next one	iterator->current_header = NULL;	free((void *)iterator->current_module_path);	iterator->current_module_path = NULL;	put_module_image(iterator->module_image);	iterator->module_image = NULL;	goto nextModuleImage;}