Smattr / clink

a modern re-implementation of Cscope
The Unlicense
43 stars 2 forks source link

tighten allocations on 'left' and 'right' in TUI #118

Closed Smattr closed 2 years ago

Smattr commented 2 years ago

This change has two primary motivations:

  1. The left_size and right_size variables are no longer maintained. The allocated size of each string is simply strlen(left) + 1 and strlen(right) + 1, respectively. This removes the possibility for state drifting out of sync.

  2. The system allocator is now aware of the exact extent of these strings. This should help ASan/Valgrind/etc catch misuses.

We possibly lose some optimisation in this change, but it is not relevant as all this code is in logic where the user is interacting with the system. That is, we spend most of our time waiting for the user to type a character anyway.