commit - 078e971d4f71f224136916ca245ed368072f3c05
commit + 0d26ce361e0d50e331fac03e817a72a4d1edcfe7
blob - 27eab4c76697959df3eabaa6437bcc6ccec0fe44
blob + c8e773f37bd9412ed0428d83db0624e1f358ba84
--- lib/diff3.c
+++ lib/diff3.c
#include "got_lib_diff.h"
#include "worklist.h"
+#ifndef nitems
+#define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
+#endif
+
/* flags shared between merge(1) and rcsmerge(1) */
#define MERGE_EFLAG (1<<16)
#define MERGE_OFLAG (1<<17)
size_t dlen, plen;
struct wklhead temp_files;
struct diff3_state *d3s;
+ int i;
*buf = NULL;
worklist_clean(&temp_files, worklist_unlink);
+ for (i = 0; i < nitems(d3s->fp); i++) {
+ if (d3s->fp[i])
+ fclose(d3s->fp[i]);
+ }
+ free(d3s);
if (err == NULL)
*buf = diffb;
return err;
if ((n = readin(dp23, &d3s->d23, d3s)) < 0)
return got_error_from_errno();
- /* XXX LEAK: at present we never close these files! */
if ((d3s->fp[0] = fopen(path1, "r")) == NULL)
return got_error_from_errno();
if ((d3s->fp[1] = fopen(path2, "r")) == NULL)