- int srclen = strlen(src);
- int dstlen = strlen(dst);
- char *srcbase = malloc(srclen + pathlen1 + 2);
- char *dstbase = malloc(srclen + pathlen1 + 2);
- memcpy(srcbase, src, srclen);
- memcpy(srcbase + srclen, path1, pathlen1);
- memcpy(srcbase + srclen + pathlen1, "/", 2);
- memcpy(dstbase, dst, dstlen);
- memcpy(dstbase + dstlen, path2, pathlen2);
- memcpy(dstbase + dstlen + pathlen2, "/", 2);
- return diff_tree_sha1(sha1, sha2, srcbase, dstbase);
+ int retval;
+ int baselen = strlen(base);
+ char *newbase = malloc(baselen + pathlen1 + 2);
+ memcpy(newbase, base, baselen);
+ memcpy(newbase + baselen, path1, pathlen1);
+ memcpy(newbase + baselen + pathlen1, "/", 2);
+ retval = diff_tree_sha1(sha1, sha2, newbase);
+ free(newbase);
+ return retval;