Reuse, not rework

License Awareness

Highly Reusable Software

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


librock_z_adler32 - Checksum function from zlib
librock_z_crc32 - Checksum function from zlib
#License - #Source code - #Example Use -


These functions do not perform compress/uncompress, but they are used for integrity checks.
#include <librock/target/types.c>
#include <librock/zlibh.h>

librock_z_adler32(librock_z_uLong adler,
                   const librock_z_Bytef *buf,
                   librock_z_uInt len);
Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example:

     librock_z_uLong adler = librock_z_adler32(0L, librock_z_Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       adler = librock_z_adler32(adler, buffer, length);
     if (adler != original_adler) error();

librock_z_crc32(librock_z_uLong crc,
                   const librock_z_Bytef *buf,
                   librock_z_uInt len);
Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. This means that the required initial value is 0, but the code below has the recommended initialization.

Note that librock already includes a function librock_CRC32, with a very similar implementation. Since the API is slightly different, they are not replacement compatible.

Usage example:

     librock_z_uLong crc = librock_z_crc32(0L, librock_Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       crc = librock_z_crc32(crc, buffer, length);
     if (crc != original_crc) error();


//No external calls

MT Behavior

These functions are well-behaved in multi-threaded environments. The zlib functions do not install any signal handler, and return error codes instead of exiting or throwing exceptions. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input.


    Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License text in <librock/license/zlib.txt> librock_LIDESC_HC=d49ece91d0f3402f1ca405bc4ae7b2a989a56ab2

Source Code

acquired/zlib/adler32.c (implementation of librock_z_adler32)
acquired/zlib/zcrc32.c (implementation of librock_z_crc32)
./librock/zlibh.h (source of this manual page)

This software is part of Librock

Rapid reuse, without rework. Details
This page copyright (C) 2002-2003 Forrest J. Cavalier III, d-b-a Mib Software, Saylorsburg PA 18353, USA

Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)

Want to help? We welcome comments, patches. -- Need help? Request paid support.