You mean to replace this line : 

r_data = (MCDataRef) realloc(t_data, t_length);

with 

/* UNCHECKED */ MCDataCreateWithBytesAndRelease((byte_t *) t_data, (uindex_t) t_length, r_data); 

, right?