Note that size can be NULL.
Fixes a build error on darwin.

Simplifies the code some as well.