Logo Search packages:      
Sourcecode: easyh10 version File versions  Download package

h10db_t* h10db_new ( int  flags  ) 

Create an instance of h10db_t.

Parameters:
flags The flags.
Returns:
The pointer to the instance if succeeded, otherwise NULL.

Definition at line 276 of file h10db.c.

{
      h10db_t* h10db = (h10db_t*)malloc(sizeof(h10db_t));
      if (h10db) {
            h10db->type = (h10db_type_t*)malloc(sizeof(h10db_type_t));
            h10db->hdr = (h10db_hdr_t*)malloc(sizeof(h10db_hdr_t));
            if (h10db->type && h10db->hdr) {
                  h10db_type_init(h10db->type, flags);

                  h10db->dat = NULL;
                  h10db->idx = NULL;
                  
                  /* Disabled H10DB.upd usage. */
                  h10db->upd = NULL;
#ifdef      H10DB_USE_UPD
                  if (flags & H10DB_FLAG_INCREMENTAL) {
                        h10db->upd = (h10db_upd_t*)malloc(sizeof(h10db_upd_t));
                        if (h10db->upd) {
                              h10db_upd_read(h10db->upd, NULL);   /* Not reading but initialization. */
                        }
                        /* We don't care for the case (h10db->upd == NULL). */
                  } else {
                        h10db->upd = NULL;
                  }
#endif

                  h10db->flags = flags;

                  h10db->progress_func = NULL;
                  h10db->error_func = NULL;
                  h10db->instance = NULL;

                  /* Initialize hdr using template */
                  h10db_hdr_init(
                        h10db->hdr,
                        h10db_model_get_maxentries(h10db->type),
                        h10db_model_get_padding(h10db->type),
                        h10db_model_has_hdr_unknown5(h10db->type)
                        );
                  h10db->hdr->num_dat_entries = 0;
                  h10db->hdr->num_dat_inactive_entries = 0;
            } else {
                  free(h10db);
                  h10db = NULL;
            }
      }
      return h10db;
}


Generated by  Doxygen 1.6.0   Back to index