Reduce duplication of platform-specific allocation code.
Created attachment 62936 [details] Preliminary patch, requires more testing, changelog adding, etc
Created attachment 63629 [details] patch
fixed in r64782.