Extend database memory.
MCO_RET mco_db_extend( /*IN*/ const char * dbname /*IN*/ void * mem, /*IN*/ uint4 size);
dbname | The name of the database to extend |
mem | The starting address of a block of memory |
size |
The size, in bytes, of the block of memory |
This function extends the amount of memory used by the database
dbname
.
MCO_S_OK | The database was created successfully |
MCO_E_NOINSTANCE | The specified database is not opened |
MCO_ERR_TRN | A database transaction error occurred. (eg. The database is already opened by some other thread that has an open transaction.) |
Application snippet: const char * dbname = "SimpleDb"; int main(int argc, char* argv[]) { mco_db_h db; MCO_RET rc; mco_device_t dev; mco_db_params_t db_params; uint4 free_pages; uint4 total_pages; if( (rc = mco_runtime_start()) != MCO_S_OK) exit(-1); ... rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params); ... rc = mco_db_connect(dbname, &db); ... /* If low memory situation detected (see "Auxiliary APIs: Statistics") */ mco_db_free_pages(db, &freepages); mco_db_total_pages(db, &totalpages ); if(freepages < totalpages / 10) { // yes. Extend the database char * mem2 = malloc(SECOND_SEGSZ); if( mem2 ) { rc = mco_db_extend(dbname, mem2, SECOND_SEGSZ); ... } } }