diff --git a/diff-delta.c b/diff-delta.c
index c61887518874d550f66d2d52bd7559d023fcb176..8b9172aa2ef7402b0a847815bb11a26d1c4444fe 100644 (file)
--- a/diff-delta.c
+++ b/diff-delta.c
#include <string.h>
#include "delta.h"
#include <string.h>
#include "delta.h"
+#include "git-compat-util.h"
/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64
/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64
const void *src_buf;
unsigned long src_size;
unsigned int hash_mask;
const void *src_buf;
unsigned long src_size;
unsigned int hash_mask;
- struct index_entry *hash[0];
+ struct index_entry *hash[FLEX_ARRAY];
};
struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
};
struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
entry->next = hash[i];
hash[i] = entry++;
hash_count[i]++;
entry->next = hash[i];
hash[i] = entry++;
hash_count[i]++;
- entries--;
}
}
}
}
@@ -230,10 +230,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
}
free(hash_count);
}
free(hash_count);
- /* If we didn't use all hash entries, free the unused memory. */
- if (entries)
- index = realloc(index, memsize - entries * sizeof(*entry));
-
return index;
}
return index;
}
ref_data = index->src_buf;
ref_top = ref_data + index->src_size;
data = trg_buf;
ref_data = index->src_buf;
ref_top = ref_data + index->src_size;
data = trg_buf;
- top = trg_buf + trg_size;
+ top = (const unsigned char *) trg_buf + trg_size;
outpos++;
val = 0;
outpos++;
val = 0;