convert malloc use under libc-internal locks to use internal allocator