Small changee takes care of the following valgrind messages:

==32343== Source and destination overlap in memcpy(0x4192492c, 0x4192492c, 20)
==32343==    at 0x40020351: memcpy (mac_replace_strmem.c:95)
==32343==    by 0x80BC95B: scramble (common/gamecode/economy.c:132)
==32343==    by 0x80BCA71: expandorders (common/gamecode/economy.c:169)
==32343==    by 0x80BCB75: expandrecruit (common/gamecode/economy.c:199)
==32343==
==32343== Source and destination overlap in memcpy(0x443f3de0, 0x443f3de0, 20)
==32343==    at 0x40020351: memcpy (mac_replace_strmem.c:95)
==32343==    by 0x80BC95B: scramble (common/gamecode/economy.c:132)
==32343==    by 0x80BCA71: expandorders (common/gamecode/economy.c:169)
==32343==    by 0x80C31A4: expandtax (common/gamecode/economy.c:3108)
==32343==
==32343== Source and destination overlap in memcpy(0x425a5b4c, 0x425a5b4c, 20)
==32343==    at 0x40020351: memcpy (mac_replace_strmem.c:95)
==32343==    by 0x80BC95B: scramble (common/gamecode/economy.c:132)
==32343==    by 0x80BCA71: expandorders (common/gamecode/economy.c:169)
==32343==    by 0x80C09C3: expandbuying (common/gamecode/economy.c:1949)
==32343==
==32343== Source and destination overlap in memcpy(0x425a78e0, 0x425a78e0, 20)
==32343==    at 0x40020351: memcpy (mac_replace_strmem.c:95)
==32343==    by 0x80BC95B: scramble (common/gamecode/economy.c:132)
==32343==    by 0x80BCA71: expandorders (common/gamecode/economy.c:169)
==32343==    by 0x80C10A3: expandselling (common/gamecode/economy.c:2180)
==32343==
This commit is contained in:
Enno Rehling 2004-02-12 14:59:05 +00:00
parent 71a87e1e7e
commit 5bd3875c8f
1 changed files with 1 additions and 0 deletions

View File

@ -128,6 +128,7 @@ scramble(void *data, int n, size_t width)
assert(width<=sizeof(temp));
for (j=0;j!=n;++j) {
int k = rand() % n;
if (k==j) continue;
memcpy(temp, (char*)data+j*width, width);
memcpy((char*)data+j*width, (char*)data+k*width, width);
memcpy((char*)data+k*width, temp, width);