Coverage Report

Created: 2025-09-04 06:50

/src/zlib-ng/arch/generic/crc32_fold_c.c
Line
Count
Source (jump to first uncovered line)
1
/* crc32_fold.c -- crc32 folding interface
2
 * Copyright (C) 2021 Nathan Moinvaziri
3
 * For conditions of distribution and use, see copyright notice in zlib.h
4
 */
5
#include "zbuild.h"
6
#include "zutil.h"
7
#include "functable.h"
8
#include "crc32.h"
9
10
0
Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc) {
11
0
    crc->value = CRC32_INITIAL_VALUE;
12
0
    return crc->value;
13
0
}
14
15
0
Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
16
0
    crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
17
0
    memcpy(dst, src, len);
18
0
}
19
20
0
Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) {
21
    /* Note: while this is basically the same thing as the vanilla CRC function, we still need
22
     * a functable entry for it so that we can generically dispatch to this function with the
23
     * same arguments for the versions that _do_ do a folding CRC but we don't want a copy. The
24
     * init_crc is an unused argument in this context */
25
0
    Z_UNUSED(init_crc);
26
0
    crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
27
0
}
28
29
0
Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc) {
30
0
    return crc->value;
31
0
}