NOR: Allocate the right amount of memory
authorDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 26 Dec 2009 18:22:28 +0000 (10:22 -0800)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 26 Dec 2009 18:22:28 +0000 (10:22 -0800)
Switch to calloc() to simplify review and initialization.

src/flash/nor/core.c

index 67fd78bf74fe45016e596334b3c07ed1fa2ebecd..fe5372b6cd7cb901a752d0336289764f739708cc 100644 (file)
@@ -401,7 +401,7 @@ int flash_write_unlock(struct target *target, struct image *image,
        }
 
        /* allocate padding array */
-       padding = malloc(image->num_sections * sizeof(padding));
+       padding = calloc(image->num_sections, sizeof(*padding));
 
        /* loop until we reach end of the image */
        while (section < image->num_sections)