diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-03-01 02:15:29 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-03-01 02:15:29 +0100 |
commit | a5cfd4e8bebd7df9bc303e6a9dff776728354f48 (patch) | |
tree | b2ca893f34268fd904204b1ceb9d1084ba7ac4bb /pcitool | |
parent | 055279e09c3db9429e02874ec9620b9af357c80a (diff) | |
download | pcitool-a5cfd4e8bebd7df9bc303e6a9dff776728354f48.tar.gz pcitool-a5cfd4e8bebd7df9bc303e6a9dff776728354f48.tar.bz2 pcitool-a5cfd4e8bebd7df9bc303e6a9dff776728354f48.tar.xz pcitool-a5cfd4e8bebd7df9bc303e6a9dff776728354f48.zip |
Don't increase buffer size if only read few pages and there are still space
Diffstat (limited to 'pcitool')
-rw-r--r-- | pcitool/cli.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pcitool/cli.c b/pcitool/cli.c index bb3d9b8..8be4df6 100644 --- a/pcitool/cli.c +++ b/pcitool/cli.c @@ -1291,9 +1291,11 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_ size = 2048; bytes = 0; do { - size *= 2; - buf = realloc(buf, size); - if (!buf) Error("Allocation of %zu bytes of memory has failed", size); + if ((size - bytes) < 4096) { + size *= 2; + buf = realloc(buf, size); + if (!buf) Error("Allocation of %zu bytes of memory has failed", size); + } err = pcilib_read_dma_custom(handle, dmaid, addr, size - bytes, dma_flags, timeout, buf + bytes, &ret); bytes += ret; |