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>
11 /*****************************************************************************
14 #include <proto/arossupport.h>
23 Calculate a checksum for a given area of memory.
27 size - This many bytes. Must be a multiple of sizeof(ULONG)
30 The checksum for the memory. If you store the checksum somewhere
31 in the area and run CalcChecksum() again, the result will be 0.
32 To achieve this, you must set the place, where the checksum will
33 be placed later, to 0 before you call the function.
36 This function is not part of a library and may thus be called
42 mem[0] = 0; // Store checksum here
43 mem[0] = CalcChecksum (mem, sizeof (mem));
45 if (CalcChecksum (mem, sizeof (mem))
46 printf ("Something is wrong !!\n");
48 printf ("Data is unchanged.\n");
53 exec.library/SumKickData(), exec.library/SumLibrary()
56 The function uses the DOS way: sum all the ULONGs and return the
57 negative result. Not very safe, but then it's quite fast :)
60 26-10-95 digulla created
62 ******************************************************************************/
67 for (sum
=0, lptr
=(ULONG
*)memory
; size
>0; size
-=sizeof(ULONG
))