projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Avoid wasting memory while keeping track of what we have during fetch.
[git.git]
/
diff.c
diff --git
a/diff.c
b/diff.c
index
f8e3cbf
..
05a0663
100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-214,14
+214,10
@@
struct diff_filespec *alloc_filespec(const char *path)
{
int namelen = strlen(path);
struct diff_filespec *spec = xmalloc(sizeof(*spec) + namelen + 1);
{
int namelen = strlen(path);
struct diff_filespec *spec = xmalloc(sizeof(*spec) + namelen + 1);
+
+ memset(spec, 0, sizeof(*spec));
spec->path = (char *)(spec + 1);
spec->path = (char *)(spec + 1);
- strcpy(spec->path, path);
- spec->should_free = spec->should_munmap = 0;
- spec->xfrm_flags = 0;
- spec->size = 0;
- spec->data = NULL;
- spec->mode = 0;
- memset(spec->sha1, 0, 20);
+ memcpy(spec->path, path, namelen+1);
return spec;
}
return spec;
}
@@
-406,13
+402,14
@@
int diff_populate_filespec(struct diff_filespec *s, int size_only)
return 0;
}
return 0;
}
-void diff_free_filespec(struct diff_filespec *s)
+void diff_free_filespec
_data
(struct diff_filespec *s)
{
if (s->should_free)
free(s->data);
else if (s->should_munmap)
munmap(s->data, s->size);
{
if (s->should_free)
free(s->data);
else if (s->should_munmap)
munmap(s->data, s->size);
- free(s);
+ s->should_free = s->should_munmap = 0;
+ s->data = NULL;
}
static void prep_temp_blob(struct diff_tempfile *temp,
}
static void prep_temp_blob(struct diff_tempfile *temp,
@@
-771,8
+768,8
@@
struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
void diff_free_filepair(struct diff_filepair *p)
{
void diff_free_filepair(struct diff_filepair *p)
{
- diff_free_filespec(p->one);
- diff_free_filespec(p->two);
+ diff_free_filespec
_data
(p->one);
+ diff_free_filespec
_data
(p->two);
free(p);
}
free(p);
}