summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c80522e)
raw | patch | inline | side by side (parent: c80522e)
author | Linus Torvalds <torvalds@osdl.org> | |
Wed, 14 Sep 2005 20:41:24 +0000 (13:41 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 14 Sep 2005 20:57:34 +0000 (13:57 -0700) |
This simplifies and fixes the initialization of a "diff_filespec" when
allocated.
The old code would not initialize "sha1_valid". Noticed by valgrind.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
allocated.
The old code would not initialize "sha1_valid". Noticed by valgrind.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c | patch | blob | history |
index f8e3cbf1a652de273ee3a9b98c09eefc268f9977..1059049fb99ae45fcfb81f3bf9ebb19005c67561 100644 (file)
--- a/diff.c
+++ b/diff.c
{
int namelen = strlen(path);
struct diff_filespec *spec = xmalloc(sizeof(*spec) + namelen + 1);
+
+ memset(spec, 0, sizeof(*spec));
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;
}