Config constructor

Config()

Creates a default Zenoh configuration.

Throws ZenohException if the native config creation fails.

Implementation

Config() : _ptr = calloc.allocate<Void>(bindings.zd_config_sizeof()) {
  final rc = bindings.zd_config_default(_ptr.cast());
  if (rc != 0) {
    calloc.free(_ptr);
    throw ZenohException('Failed to create default config', rc);
  }
  // AFTER the rc check, never before. A throw here has already freed the
  // block, and a finalizer attached to the half-built object would hand that
  // same address to `free()` again when it was collected.
  _attachNet();
}