Example #1
0
int NaClDescCtor(struct NaClDesc *ndp) {
  /* this should be a compile-time test */
  if (0 != (sizeof(struct NaClInternalHeader) & 0xf)) {
    NaClLog(LOG_FATAL,
            "Internal error.  NaClInternalHeader size not a"
            " multiple of 16\n");
  }
  ndp->flags = 0;
  ndp->metadata_type = NACL_DESC_METADATA_TYPE_NONE;
  ndp->metadata_num_bytes = 0;
  ndp->metadata = NULL;
  return NaClRefCountCtor(&ndp->base);
}
int NaClReverseInterfaceCtor_protected(
    struct NaClReverseInterface   *self) {
  NaClLog(4, "Entered NaClReverseInterfaceCtor_protected\n");
  if (!NaClRefCountCtor((struct NaClRefCount *) self)) {
    NaClLog(4,
            "NaClReverseInterfaceCtor_protected: "
            "NaClRefCountCtor base class ctor failed\n");
    return 0;
  }
  NACL_VTBL(NaClRefCount, self) =
      (struct NaClRefCountVtbl const *) &kNaClReverseInterfaceVtbl;
  NaClLog(4,
          "Leaving NaClReverseInterfaceCtor_protected, returning 1\n");
  return 1;
}
static int NaClSimpleServiceCtorIntern(
    struct NaClSimpleService          *self,
    struct NaClSrpcHandlerDesc const  *srpc_handlers,
    NaClThreadIfFactoryFunction       thread_factory_fn,
    void                              *thread_factory_data) {
  NaClLog(4,
          "NaClSimpleServiceCtorIntern, self 0x%"NACL_PRIxPTR"\n",
          (uintptr_t) self);
  if (!NaClRefCountCtor((struct NaClRefCount *) self)) {
    NaClLog(4, "NaClSimpleServiceCtorIntern: NaClRefCountCtor failed\n");
    return 0;
  }
  self->handlers = srpc_handlers;
  self->thread_factory_fn = thread_factory_fn;
  self->thread_factory_data = thread_factory_data;
  self->acceptor = (struct NaClThreadInterface *) NULL;

  self->base.vtbl = (struct NaClRefCountVtbl const *) &kNaClSimpleServiceVtbl;
  NaClLog(4, "Leaving NaClSimpleServiceCtorIntern\n");
  return 1;
}
int NaClSimpleServiceConnectionCtor(
    struct NaClSimpleServiceConnection  *self,
    struct NaClSimpleService            *server,
    struct NaClDesc                     *conn,
    void                                *instance_data) {
  NaClLog(4,
          "NaClSimpleServiceConnectionCtor: self 0x%"NACL_PRIxPTR"\n",
          (uintptr_t) self);
  if (!NaClRefCountCtor((struct NaClRefCount *) self)) {
    return 0;
  }
  self->server = (struct NaClSimpleService *) NaClRefCountRef(
      (struct NaClRefCount *) server);
  self->connected_socket = (struct NaClDesc *) NaClRefCountRef(
      (struct NaClRefCount *) conn);
  self->instance_data = instance_data;

  self->thread = NULL;

  self->base.vtbl = (struct NaClRefCountVtbl const *)
      &kNaClSimpleServiceConnectionVtbl;
  return 1;
}