From c77d124682741144955e4a81c01df11c9d8f9bbc Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 13:03:34 +0100 Subject: [PATCH] fixed allocation order Signed-off-by: Pascal Bauer --- fpga/lib/ips/emc.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fpga/lib/ips/emc.cpp b/fpga/lib/ips/emc.cpp index 6b0ccf2fb..c4eeabba5 100644 --- a/fpga/lib/ips/emc.cpp +++ b/fpga/lib/ips/emc.cpp @@ -113,13 +113,10 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) int ret = XST_FAILURE; uint32_t start = offset; - uint8_t *verify_data = new uint8_t[length]; - /* Reset the Flash Device. This clears the ret registers and puts * the device in Read mode. */ ret = XFlash_Reset(&xflash); if (ret != XST_SUCCESS){ - delete[] verify_data; return false; } @@ -131,26 +128,24 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) (xflash.CommandSet == XFL_CMDSET_INTEL_G18)) { ret = XFlash_Unlock(&xflash, offset, 0); if(ret != XST_SUCCESS){ - delete[] verify_data; return false; } } // Perform the Erase operation. ret = XFlash_Erase(&xflash, start, length); - if (ret != XST_SUCCESS){ - delete[] verify_data; + if (ret != XST_SUCCESS){; return false; } // Perform the Write operation. ret = XFlash_Write(&xflash, start, length, data); if (ret != XST_SUCCESS){ - delete[] verify_data; return false; } // Perform the read operation. + uint8_t *verify_data = new uint8_t[length]; ret = XFlash_Read(&xflash, start, length, verify_data); if(ret != XST_SUCCESS) { delete[] verify_data;