2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Calculate a checksum for a given area of memory
9 #include <aros/system.h>
12 /*****************************************************************************
15 #include <proto/arossupport.h>
24 Calculate a checksum for a given area of memory.
28 size - This many bytes. Must be a multiple of sizeof(ULONG)
31 The checksum for the memory. If you store the checksum somewhere
32 in the area and run CalcChecksum() again, the result will be 0.
33 To achieve this, you must set the place, where the checksum will
34 be placed later, to 0 before you call the function.
37 This function is not part of a library and may thus be called
43 mem[0] = 0; // Store checksum here
44 mem[0] = CalcChecksum (mem, sizeof (mem));
46 if (CalcChecksum (mem, sizeof (mem))
47 printf ("Something is wrong !!\n");
49 printf ("Data is unchanged.\n");
54 SumKickData(), SumLibrary()
57 The function uses the DOS way: sum all the ULONGs and return the
58 negative result. Not very safe, but then it's quite fast :)
61 26-10-95 digulla created
63 ******************************************************************************/
69 assert ((size
&(sizeof(ULONG
)-1))==0);
71 for (sum
=0, lptr
=(ULONG
*)memory
; size
>0; size
-=sizeof(ULONG
))