]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: move DRAM line buffer allocation closer to its use
authorDaniel Trnka <redacted>
Thu, 12 Mar 2020 11:08:35 +0000 (12:08 +0100)
committerUwe Hermann <redacted>
Tue, 24 Mar 2020 18:20:40 +0000 (19:20 +0100)
Move the allocation of the DRAM line buffer in the sample download code
path closer to the location where that buffer is used and gets released.

src/hardware/asix-sigma/protocol.c

index a9c1695686c10c4f6b41742fd4f09eb291d79453..268c13cc0686b833d6ce1c022c94d88bab01108f 100644 (file)
@@ -1004,10 +1004,6 @@ static int download_capture(struct sr_dev_inst *sdi)
        devc = sdi->priv;
        dl_events_in_line = 64 * 7;
 
-       dram_line = g_try_malloc0(chunks_per_read * sizeof(*dram_line));
-       if (!dram_line)
-               return FALSE;
-
        sr_info("Downloading sample data.");
        devc->state.state = SIGMA_DOWNLOAD;
 
@@ -1063,6 +1059,9 @@ static int download_capture(struct sr_dev_inst *sdi)
        } else {
                dl_first_line = 0;
        }
+       dram_line = g_try_malloc0(chunks_per_read * sizeof(*dram_line));
+       if (!dram_line)
+               return FALSE;
        dl_lines_done = 0;
        while (dl_lines_total > dl_lines_done) {
                /* We can download only up-to 32 DRAM lines in one go! */