replace malloc with calloc/realocarray where appropriate.
also some minor format fixes.
insert NULL checks before use.
Merge branch 'hf-libedit' into hellfish