Include <errno.h>, <stdlib.h>. (getgroups): First arg is int, not size_t. Don't let 'free' mangle errno.