embedded: save stack
and also do not recaluate the crc32_table upon every invocation. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>__archive__
parent
808e53368c
commit
31da0003dc
|
@ -1023,17 +1023,23 @@ int image_calculate_checksum(uint8_t* buffer, uint32_t nbytes, uint32_t* checksu
|
||||||
uint32_t crc = 0xffffffff;
|
uint32_t crc = 0xffffffff;
|
||||||
LOG_DEBUG("Calculating checksum");
|
LOG_DEBUG("Calculating checksum");
|
||||||
|
|
||||||
uint32_t crc32_table[256];
|
static uint32_t crc32_table[256];
|
||||||
|
|
||||||
/* Initialize the CRC table and the decoding table. */
|
static bool first_init = false;
|
||||||
int i, j;
|
if (!first_init)
|
||||||
unsigned int c;
|
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
{
|
||||||
/* as per gdb */
|
/* Initialize the CRC table and the decoding table. */
|
||||||
for (c = i << 24, j = 8; j > 0; --j)
|
int i, j;
|
||||||
c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
|
unsigned int c;
|
||||||
crc32_table[i] = c;
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
/* as per gdb */
|
||||||
|
for (c = i << 24, j = 8; j > 0; --j)
|
||||||
|
c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
|
||||||
|
crc32_table[i] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
first_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nbytes > 0)
|
while (nbytes > 0)
|
||||||
|
|
Loading…
Reference in New Issue