Directory Server makes a copy of the oid string.
The contents of the ber parameter are the responsibility of the caller.
You can free the ber parameter of the slapi_build_control() using ber_free (3LDAP).
The LDAPControl pointer that is returned in ctrlp should be freed by calling ldap_control_free(3LDAP), which is an LDAP API function.