directory: converted isRootDirectory() to an inline function
The function isRootDirectory() is tiny and can be converted to an inline function. Don't allow name==NULL.
This commit is contained in:
		@@ -101,11 +101,6 @@ void directory_finish(void)
 | 
				
			|||||||
	freeDirectory(music_root);
 | 
						freeDirectory(music_root);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int isRootDirectory(const char *name)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (!name || name[0] == '\0' || !strcmp(name, "/"));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct directory *
 | 
					struct directory *
 | 
				
			||||||
directory_get_root(void)
 | 
					directory_get_root(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -122,6 +117,8 @@ getSubDirectory(struct directory * directory, const char *name)
 | 
				
			|||||||
	char *duplicated;
 | 
						char *duplicated;
 | 
				
			||||||
	char *locate;
 | 
						char *locate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						assert(name != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (isRootDirectory(name))
 | 
						if (isRootDirectory(name))
 | 
				
			||||||
		return directory;
 | 
							return directory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -148,6 +145,9 @@ getSubDirectory(struct directory * directory, const char *name)
 | 
				
			|||||||
struct directory *
 | 
					struct directory *
 | 
				
			||||||
getDirectory(const char *name)
 | 
					getDirectory(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						if (name == NULL)
 | 
				
			||||||
 | 
							return music_root;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return getSubDirectory(music_root, name);
 | 
						return getSubDirectory(music_root, name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,11 @@ void directory_init(void);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void directory_finish(void);
 | 
					void directory_finish(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int isRootDirectory(const char *name);
 | 
					static inline bool
 | 
				
			||||||
 | 
					isRootDirectory(const char *name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return name[0] == 0 || (name[0] == '/' && name[1] == 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct directory *
 | 
					struct directory *
 | 
				
			||||||
directory_get_root(void);
 | 
					directory_get_root(void);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user