Lines Matching refs:iterator

831 iterator_pop_path_from_stack(module_iterator* iterator, uint32* _baseLength)
833 if (iterator->stack_current <= 0)
837 *_baseLength = iterator->stack[iterator->stack_current - 1].base_length;
839 return iterator->stack[--iterator->stack_current].name;
844 iterator_push_path_on_stack(module_iterator* iterator, const char* path,
847 if (iterator->stack_current + 1 > iterator->stack_size) {
849 module_path* stack = (module_path*)realloc(iterator->stack,
850 (iterator->stack_size + 8) * sizeof(module_path));
854 iterator->stack = stack;
855 iterator->stack_size += 8;
858 iterator->stack[iterator->stack_current].name = path;
859 iterator->stack[iterator->stack_current++].base_length = baseLength;
865 match_iterator_suffix(module_iterator* iterator, const char* name)
867 if (iterator->suffix == NULL || iterator->suffix_length == 0)
871 if (length <= iterator->suffix_length)
874 return name[length - iterator->suffix_length - 1] == '/'
875 && !strcmp(name + length - iterator->suffix_length, iterator->suffix);
880 iterator_get_next_module(module_iterator* iterator, char* buffer,
887 if (iterator->builtin_modules) {
888 for (int32 i = iterator->module_offset; sBuiltInModules[i] != NULL;
891 if (strncmp(sBuiltInModules[i]->name, iterator->prefix,
892 iterator->prefix_length)
893 || !match_iterator_suffix(iterator, sBuiltInModules[i]->name))
898 iterator->module_offset = i + 1;
901 iterator->builtin_modules = false;
904 if (iterator->loaded_modules) {
911 if (i >= iterator->module_offset) {
912 if (!strncmp(module->name, iterator->prefix,
913 iterator->prefix_length)
914 && match_iterator_suffix(iterator, module->name)) {
916 iterator->module_offset = i + 1;
924 iterator->loaded_modules = false;
928 if (iterator->current_dir == NULL) {
930 const char* path = iterator_pop_path_from_stack(iterator,
931 &iterator->path_base_length);
937 free((char*)iterator->current_path);
938 iterator->current_path = path;
939 iterator->current_dir = opendir(path);
940 TRACE(("open directory at %s -> %p\n", path, iterator->current_dir));
942 if (iterator->current_dir == NULL) {
953 if (iterator->current_header == NULL) {
959 if ((dirent = readdir(iterator->current_dir)) == NULL) {
960 closedir(iterator->current_dir);
961 iterator->current_dir = NULL;
971 passedOffset = strlen(iterator->current_path) + 1;
972 commonLength = iterator->path_base_length + iterator->prefix_length
981 if (strncmp(dirent->d_name, iterator->prefix + passedOffset
982 - iterator->path_base_length, commonLength))
996 KPath path(iterator->current_path);
1008 iterator->current_module_path = strdup(path.Path());
1009 if (iterator->current_module_path == NULL)
1013 status = iterator_push_path_on_stack(iterator,
1014 iterator->current_module_path, iterator->path_base_length);
1018 iterator->current_module_path = NULL;
1027 status = get_module_image(path.Path(), &iterator->module_image);
1029 free((char*)iterator->current_module_path);
1030 iterator->current_module_path = NULL;
1034 iterator->current_header = iterator->module_image->info;
1035 iterator->module_offset = 0;
1039 while (*iterator->current_header != NULL) {
1040 module_info* info = *iterator->current_header;
1045 iterator->current_header++;
1046 iterator->module_offset++;
1048 if (strncmp(info->name, iterator->prefix, iterator->prefix_length)
1049 || !match_iterator_suffix(iterator, info->name))
1058 iterator->current_header = NULL;
1059 free((char*)iterator->current_module_path);
1060 iterator->current_module_path = NULL;
1062 put_module_image(iterator->module_image);
1063 iterator->module_image = NULL;
1159 ModuleTable::Iterator iterator(sModulesHash);
1162 while (iterator.HasNext()) {
1163 struct module* module = iterator.Next();
1619 ModuleListenerList::Iterator iterator = fListeners.GetIterator();
1620 while (iterator.HasNext()) {
1621 module_listener* listener = iterator.Next();
1653 NotificationList::Iterator iterator = fNotifications.GetIterator();
1654 while (iterator.HasNext()) {
1655 module_notification* notification = iterator.Next();
1660 iterator.Remove();
1861 ModuleTable::Iterator iterator(sModulesHash);
1863 while (iterator.HasNext()) {
1864 module = iterator.Next();
1888 // Using RemoveUnchecked to avoid invalidating the iterator
1989 module_iterator* iterator = (module_iterator*)malloc(
1991 if (iterator == NULL)
1994 memset(iterator, 0, sizeof(module_iterator));
1996 iterator->prefix = strdup(prefix != NULL ? prefix : "");
1997 if (iterator->prefix == NULL) {
1998 free(iterator);
2001 iterator->prefix_length = strlen(iterator->prefix);
2003 iterator->suffix = suffix;
2005 iterator->suffix_length = strlen(iterator->suffix);
2011 iterator->builtin_modules = true;
2012 iterator->loaded_modules = false;
2027 // Copy base path onto the iterator stack
2035 // version below, but the iterator won't work if the prefix
2041 char* path = (char*)malloc(length + iterator->prefix_length + 2);
2050 memcpy(path + length + 1, iterator->prefix,
2051 iterator->prefix_length + 1);
2054 iterator_push_path_on_stack(iterator, path, length + 1);
2058 iterator->builtin_modules = false;
2059 iterator->loaded_modules = true;
2062 return (void*)iterator;
2077 module_iterator* iterator = (module_iterator*)cookie;
2082 if (iterator == NULL)
2086 while ((path = iterator_pop_path_from_stack(iterator, NULL)) != NULL)
2090 if (iterator->module_image != NULL)
2091 put_module_image(iterator->module_image);
2093 if (iterator->current_dir != NULL)
2094 closedir(iterator->current_dir);
2096 free(iterator->stack);
2097 free((char*)iterator->current_path);
2098 free((char*)iterator->current_module_path);
2100 free(iterator->prefix);
2101 free(iterator);
2115 module_iterator* iterator = (module_iterator*)cookie;
2120 if (iterator == NULL || buffer == NULL || _bufferSize == NULL)
2123 if (iterator->status < B_OK)
2124 return iterator->status;
2126 status = iterator->status;
2129 status = iterator_get_next_module(iterator, buffer, _bufferSize);
2131 iterator->status = status;
2163 ModuleTable::Iterator iterator(sModulesHash);
2165 for (uint32 i = 0; iterator.HasNext(); i++) {
2166 struct module* module = iterator.Next();