add: atomic_add(&mlc->ma->ref_count, 1);
context: _EXPORT status_t read_next_module_name(void *cookie, char *buf, size_t *bufsize){	module_list_cookie * mlc = (module_list_cookie *) cookie;		if (!bufsize)		return B_BAD_VALUE;		if (!mlc)		return B_BAD_VALUE;			/* Okay, take some time to understand how this function works!	   Basicly, we iterate thru:	   - each searchable add-ons path root	   - each (sub-)directory under the current add-ons path root	   - each module add-on file in the current (sub-)directory	   - each module name published by current module add-on	   	   As the iteration involve sub-directory walks, we use recursive calls.	   Sorry if this code sounds too complex...	*/	if (mlc->ma && mlc->mi) {		// we have a module addon still loaded from a last call		// so keep looking at his exported module names list		while (*mlc->mi) {			module_info * mi = *mlc->mi;			mlc->mi++;			if(strstr(mi->name, mlc->prefix)) {				// We find a matching module name. At least. Yeah!!!				if (buf) strncpy(buf, mi->name, *bufsize);				*bufsize = strlen(mi->name);				return B_OK;			};		};				// We've iterate all module names of this module addon. Find another one...		unload_module_addon(mlc->ma);		mlc->ma = NULL;		mlc->mi = NULL;	};			// Iterate all searchable add-ons paths	while (mlc->search_path) {		BDirectory * dir;		BEntry entry;		BPath path;		status_t status;					// Get current directory		dir = (BDirectory *) mlc->dir_stack->LastItem();		if (!dir) {			// find add-ons root directory in this search path			if (strncmp(mlc->search_path, "%A/", 3) == 0) {				// resolve "%A/..." path				app_info ai;								be_app->GetAppInfo(&ai);				entry.SetTo(&ai.ref);				entry.GetPath(&path);				path.GetParent(&path);				path.Append(mlc->search_path + 3);			} else {				path.SetTo(mlc->search_path);			};						// We look *only* under prefix-matching sub-path 			path.Append(mlc->prefix);			// printf("Looking module(s) in %s/%s...\n", mlc->search_path, mlc->prefix);			 			dir = new BDirectory(path.Path());			if (dir)				mlc->dir_stack->AddItem(dir);		};				// Iterate current directory content		if (dir) {  			while (dir->GetNextEntry(&entry) == B_OK) {				entry.GetPath(&path);				// printf("  %s ?\n", path.Path());				if (entry.IsDirectory()) {					BDirectory * subdir;					// push this directory on dir_stack					subdir = new BDirectory(path.Path());					if (!subdir)						continue;											mlc->dir_stack->AddItem(subdir);					// recursivly search this sub-directory					return read_next_module_name(cookie, buf, bufsize);				};								if (entry.IsFile() || entry.IsSymLink()) {					mlc->ma = load_module_addon(path.Path());		            if (!mlc->ma)		            	// Oh-oh, not a loadable module addon!?		            	// WTF it's doing there?!?						continue;					// call ourself to enter the module names list iteration at					// function begining code...					mlc->mi = mlc->ma->infos;					return read_next_module_name(cookie, buf, bufsize);				};			};						// We walk thru all this directory content, go back to parent			status = mlc->dir_stack->RemoveItem(dir);			delete dir;		};				if (!mlc->dir_stack->IsEmpty())			continue;					// We walk thru all this search path content, next now 		mlc->search_path = strtok_r(NULL, ":", &mlc->next_path_token);	};	// Module(s) list search done, ending...	return B_ERROR;		}