- stops multiple calls to examine from allocating the breakpoint arrays
[openocd.git] / src / target / image.c
index 793a811f6724ba901a63aa6618b4663c5c960c2e..a8753ac9c5a1f0fbd5408f14f623a4541e769cd8 100644 (file)
@@ -912,7 +912,7 @@ int image_add_section(image_t *image, u32 base, u32 size, int flags, u8 *data)
        return ERROR_OK;
 }
 
-int image_close(image_t *image)
+void image_close(image_t *image)
 {
        if (image->type == IMAGE_BINARY)
        {
@@ -994,40 +994,44 @@ int image_close(image_t *image)
                free(image->sections);
                image->sections = NULL;
        }
-
-       return ERROR_OK;
 }
 
-static u32 crc32_table[256] = {0, 0};
-
 int image_calculate_checksum(u8* buffer, u32 nbytes, u32* checksum)
 {
        u32 crc = 0xffffffff;
+       LOG_DEBUG("Calculating checksum");
+
+       u32 crc32_table[256];
 
-       if (!crc32_table[1])
+       /* Initialize the CRC table and the decoding table.  */
+       int i, j;
+       unsigned int c;
+       for (i = 0; i < 256; i++)
        {
-               /* Initialize the CRC table and the decoding table.  */
-               int i, j;
-               unsigned int 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;
-               }
+               /* as per gdb */
+               for (c = i << 24, j = 8; j > 0; --j)
+                       c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
+               crc32_table[i] = c;
        }
 
-       while (nbytes--)
+       while (nbytes>0)
        {
-               /* as per gdb */
-               crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buffer++) & 255];
-               if ((nbytes%16384)==0)
+               int run=nbytes;
+               if (run>32768)
+               {
+                       run=32768;
+               }
+               nbytes-=run;
+               while (run--)
                {
-                       keep_alive();
+                       /* as per gdb */
+                       crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buffer++) & 255];
                }
+               keep_alive();
        }
 
+       LOG_DEBUG("Calculating checksum done");
+
        *checksum = crc;
        return ERROR_OK;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)