- hdr = talloc_asprintf(dir, "%s/%s.h", dir, talloc_basename(dir, dir));
- contents = talloc_grab_file(dir, hdr, NULL);
+ hdr = tal_fmt(dir, "%s.h",
+ path_join(NULL, dir, take(path_basename(NULL, dir))));
+
+ contents = tal_grab_file(dir, hdr, NULL);