Manually implement strndup

Mac and Windows don't appear to have that function, so just implement the
poor man's version by hand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>