Merge smerrill's Varnish 4 fixes + malloc support

These changes look good - I take it you're happy with me merging @smerrill ?