Hi Andreas, Paul and Simon. On Mon, 11 Nov 2013 14:35:03 +0100, Andreas Fritiofson wrote: > On Mon, Nov 11, 2013 at 2:22 PM, Paul Fertser <[email protected]> wrote: >> What was the reason you commented out realloc() code initially, are >> there any gotchas that should be taken into account? > > I haven't looked at the code, but why not split the scan into > multiple smaller ones as an alternative to allocating larger and > larger buffers?
I know on some systems, malloc can't handle buffers larger than 1MB. What I usually do is that I have a 'master'/'scratch' buffer, which only grows. I receive the data into the maser-buffer, then when all is received, I allocate a buffer of the exact size and copy the data. Only if the data doesn't fit in the master-buffer, I enlarge it by -say- 5%. This reduces the time being spent in realloc. But sometimes I also use daisy-chaining (eg. pointer to 'next', plus a 'length' field in the beginning). Love Jens ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
