chiark / gitweb /
avoid crashes on log client teardown
[disorder] / lib / trackname.c
index cef77b85ee6ca5ad71206f823b2c6cadf57fa6ef..53824d73df8b593fd8275a2583ca64e32fe60d2d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2005, 2006 Richard Kettlewell
+ * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 #include "filepart.h"
 #include "words.h"
 
-const char *find_track_root(const char *track) {
+const struct collection *find_track_collection(const char *track) {
   int n;
   size_t l, tl = strlen(track);
 
@@ -44,11 +44,18 @@ const char *find_track_root(const char *track) {
        && track[l] == '/')
       break;
   }
-  if(n >= config->collection.n) {
-    error(0, "found track in no collection '%s'", track);
+  if(n < config->collection.n)
+    return &config->collection.s[n];
+  else
     return 0;
-  }
-  return config->collection.s[n].root;
+}
+
+const char *find_track_root(const char *track) {
+  const struct collection *c = find_track_collection(track);
+  if(c)
+    return c->root;
+  error(0, "found track in no collection '%s'", track);
+  return 0;
 }
 
 const char *track_rootless(const char *track) {