No need to malloc for len. Just pass the address.