+ *result = path;
+ return length;
+}
+
+/* Return the leading directories part of PATH,
+ allocated with malloc. If out of memory, return 0.
+ Works properly even if there are trailing slashes
+ (by effectively ignoring them). */
+
+char *
+dir_name (const char *path)
+{
+ const char *result;
+ size_t length = dir_name_r (path, &result);
+ char *newpath = (char *) malloc (length + 1);