embedded: save stack

and also do not recaluate the crc32_table upon
every invocation.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
__archive__
Øyvind Harboe 2009-11-21 23:45:36 +01:00
parent 808e53368c
commit 31da0003dc
1 changed files with 15 additions and 9 deletions

View File

@ -1023,8 +1023,11 @@ 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];
static bool first_init = false;
if (!first_init)
{
/* Initialize the CRC table and the decoding table. */ /* Initialize the CRC table and the decoding table. */
int i, j; int i, j;
unsigned int c; unsigned int c;
@ -1036,6 +1039,9 @@ int image_calculate_checksum(uint8_t* buffer, uint32_t nbytes, uint32_t* checksu
crc32_table[i] = c; crc32_table[i] = c;
} }
first_init = true;
}
while (nbytes > 0) while (nbytes > 0)
{ {
int run = nbytes; int run = nbytes;