Add function to allocate objects