diff options
author | Øyvind Harboe <oyvind.harboe@zylin.com> | 2009-11-22 19:57:57 +0100 |
---|---|---|
committer | Øyvind Harboe <oyvind.harboe@zylin.com> | 2009-11-22 19:57:57 +0100 |
commit | 5985dee35da3ea24f1c9cb30b6cd50aa1bc63660 (patch) | |
tree | 81d36a0aef73e646f2ed0bbc27a7084356f900e8 | |
parent | bcebce3ce25465589d379c809a12e2beda8430b9 (diff) | |
download | openocd+libswd-5985dee35da3ea24f1c9cb30b6cd50aa1bc63660.tar.gz openocd+libswd-5985dee35da3ea24f1c9cb30b6cd50aa1bc63660.tar.bz2 openocd+libswd-5985dee35da3ea24f1c9cb30b6cd50aa1bc63660.tar.xz openocd+libswd-5985dee35da3ea24f1c9cb30b6cd50aa1bc63660.zip |
arm11: do not use dynamic arrays
Allocate working memory dynamically, caught by checkstack.pl
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | src/target/arm11_dbgtap.c | 9 |
2 files changed, 8 insertions, 4 deletions
@@ -309,7 +309,8 @@ fairly easy to complete: - use dynamic allocations for working memory. Scan & fix code for excessive stack allocations. take linux/scripts/checkstack.pl and -see what the worst offenders are. Example, on amd64: +see what the worst offenders are. Dynamic stack allocations are found +at the bottom of the list below. Example, on amd64: $ objdump -d | checkstack.pl | head -10 0x004311e3 image_open [openocd]: 13464 diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index 0f7e4953..26de4ceb 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -880,10 +880,11 @@ int arm11_sc7_run(struct arm11_common * arm11, struct arm11_sc7_action * actions */ void arm11_sc7_clear_vbw(struct arm11_common * arm11) { - struct arm11_sc7_action clear_bw[arm11->brp + arm11->wrp + 1]; + size_t clear_bw_size = arm11->brp + arm11->wrp + 1; + struct arm11_sc7_action *clear_bw = malloc(sizeof(struct arm11_sc7_action) * clear_bw_size); struct arm11_sc7_action * pos = clear_bw; - for (size_t i = 0; i < ARRAY_SIZE(clear_bw); i++) + for (size_t i = 0; i < clear_bw_size; i++) { clear_bw[i].write = true; clear_bw[i].value = 0; @@ -899,7 +900,9 @@ void arm11_sc7_clear_vbw(struct arm11_common * arm11) (pos++)->address = ARM11_SC7_VCR; - arm11_sc7_run(arm11, clear_bw, ARRAY_SIZE(clear_bw)); + arm11_sc7_run(arm11, clear_bw, clear_bw_size); + + free (clear_bw); } /** Write VCR register |