You should not free the berval structure unless you plan to replace it by calling slapi_value_set_berval() .