diff options
author | Russell Belfer <rb@github.com> | 2013-06-07 09:54:33 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-06-07 09:54:33 -0700 |
commit | 3e9e6cdaff8acb11399736abbf793bf2d000d037 (patch) | |
tree | 4e1f3ed201309ae8a3668091e7952c26b6e7a836 /src/util.c | |
parent | 1a42dd17eb2c35fa572418f5958595cbe297d229 (diff) | |
download | libgit2-3e9e6cdaff8acb11399736abbf793bf2d000d037.tar.gz |
Add safe memset and use it
This adds a `git__memset` routine that will not be optimized away
and updates the places where I memset() right before a free() call
to use it.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index da15a039d..248cf4c42 100644 --- a/src/util.c +++ b/src/util.c @@ -722,3 +722,13 @@ void git__insertsort_r( if (freeswap) git__free(swapel); } + +void git__memset(void *data, int c, size_t size) +{ + volatile uint8_t *scan = data; + uint8_t *end = scan + size; + uint8_t val = (uint8_t)c; + + while (scan < end) + *scan++ = val; +} |