Allocate space only for n_attrs number of pointers

Currently, we are allocating space for the entire object but accessing only the pointers allocated with that space. This modification addresses that issue making sure that we only allocate space only for the pointers that we need.