]> granicus.if.org Git - flex/commit
Avoid realloc on every call of sf_push()
authorTobias Klauser <tklauser@distanz.ch>
Thu, 28 Apr 2016 08:12:52 +0000 (10:12 +0200)
committerTobias Klauser <tklauser@distanz.ch>
Thu, 28 Apr 2016 08:18:21 +0000 (10:18 +0200)
commit0afeed389c9b3e310e4f70b0b3b7fc89b1688fa1
tree932ce107899a7190eb3db21dfb58ceb0c0241bcb
parent2061043d3d277012bd98b4107a5add53c1919254
Avoid realloc on every call of sf_push()

Currently, every call to sf_push() realloc()'s _sf_stack, even if the
maximum size _sf_max wasn't changed. As the indentation beneath the
"if" clause already indicates, the realloc() should only be executed
if _sf_max was increased.

Found by compiling flex with the -Wmisleading-indentation flags of gcc,
which leads to the following warning:

scanflags.c: In function ‘sf_push’:
scanflags.c:42:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (_sf_top_ix + 1 >= _sf_max)
     ^~
scanflags.c:44:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
         _sf_stk = realloc(_sf_stk, sizeof(scanflags_t) * _sf_max);
         ^~~~~~~
src/scanflags.c