FreeBSD fix

Added mempcpy, freebsd compatibility.