本文整理汇总了C++中sp_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_destroy函数的具体用法?C++ sp_destroy怎么用?C++ sp_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compact_delete_node1
static void
compact_delete_node1(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_setint(env, "compaction.node_size", 524288 /* 512K */) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
int key = 0;
char value[100];
memset(value, 0, sizeof(value));
while (key < 13000) {
void *o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
t( sp_getint(env, "db.test.index.node_count") == 2 );
key = 0;
while (key < 5511 ) {
void *o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_delete(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
t( sp_getint(env, "db.test.index.node_count") == 1 );
void *o = sp_object(db);
void *cur = sp_cursor(db, o);
while ((o = sp_get(cur, NULL))) {
t( sp_delete(db, o) == 0 );
key++;
sp_destroy(o);
}
sp_destroy(cur);
t( key == 13000 );
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
t( sp_getint(env, "db.test.index.node_count") == 1 );
t( sp_destroy(env) == 0 );
}
示例2: db_init
sophiadb_t* db_init(void * conf) {
conf_t * pconf = (conf_t *)conf;
printf("size of datatype = %d\n",pconf->max_num);
sophiadb_t* db = (sophiadb_t*) calloc(pconf->max_num, sizeof(sophiadb_t));
if (!db) {
printf("error alloc size=%lu\n", sizeof(sophiadb_t));
exit(1);
}
assert(db);
datatype_t * p = (datatype_t *)pconf->list_datatypes;
spcmpf fcmp ;
while(p) {
fcmp = cmp0;
if (p->number <= 0) {
printf("error config parametr: number=%d \n", p->number );
free(db);
return NULL;
}
db[p->number-1].type = p->type;
db[p->number-1].datadir = p->datadir;
switch (p->type) {
case SPHDB_INT :
db[p->number-1].datalen = sizeof(int32_t);
fcmp = cmp32;
break;
case SPHDB_LONG :
db[p->number-1].datalen = sizeof(int64_t);
fcmp = cmp64;
break;
case SPHDB_STRING :
db[p->number-1].datalen = SPHDB_STRLEN;
break;
default:
printf("error: undefined config datatype\n");
free(db);
exit(1);
}
printf("fcmp: fcmp=%x\n", fcmp);
db[p->number-1].env = sp_env();
if (db[p->number-1].env == NULL) {
/* memory allocation error */
printf("env error\n");
free(db);
exit(1);
}
int rc = sp_ctl(db[p->number-1].env, SPDIR, SPO_CREAT|SPO_RDWR, p->datadir);
if (rc == -1) {
/* memory allocation error */
printf("error: %s\n", sp_error(db[p->number-1].env));
sp_destroy(db[p->number-1].env);
free(db);
exit(1);
}
if (fcmp != cmp0) {
printf("%s type=%d %x\n", p->datadir, p->type , fcmp);
rc = sp_ctl(db[p->number-1].env, SPCMP, fcmp, NULL);
if (rc == -1) {
/* memory allocation error */
printf("error: %s\n", sp_error(db[p->number-1].env));
sp_destroy(db[p->number-1].env);
free(db);
exit(1);
}
}
db[p->number-1].db = sp_open(db[p->number-1].env);
if (db[p->number-1].db == NULL) {
printf("sp_open: %s\n", sp_error(db[p->number-1].env));
sp_destroy(db[p->number-1].env);
exit(1);
}
p = p->next;
}
printf("db is open %s\n", pconf->datadir );
return db;
}
示例3: ddl_create_online2
static void
ddl_create_online2(void)
{
rmrf("./logdir");
rmrf("./dir0");
rmrf("./dir1");
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "s0", 0) == 0 );
t( sp_setstring(env, "db.s0.path", "dir0", 0) == 0 );
t( sp_setstring(env, "db.s0.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.s0.sync", 0) == 0 );
void *s0 = sp_getobject(env, "db.s0");
t( s0 != NULL );
t( sp_open(s0) == 0 );
int key = 7;
void *o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
key = 8;
o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
key = 9;
o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
t( sp_setstring(env, "db", "s1", 0) == 0 );
t( sp_setstring(env, "db.s1.path", "dir1", 0) == 0 );
t( sp_setstring(env, "db.s1.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.s1.sync", 0) == 0 );
void *s1 = sp_getobject(env, "db.s1");
t( s1 != NULL );
t( sp_open(s1) == 0 );
key = 7;
o = sp_object(s1);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s1, o) == 0 );
key = 8;
o = sp_object(s1);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s1, o) == 0 );
key = 9;
o = sp_object(s1);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s1, o) == 0 );
t( sp_destroy(s1) == 0 );
t( sp_destroy(s0) == 0 );
t( sp_destroy(env) == 0 );
rmrf("./logdir");
rmrf("./dir0");
rmrf("./dir1");
}
示例4: snapshot_test1
static void
snapshot_test1(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(db) == 0 );
int key = 0;
while (key < 10) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_getint(env, "scheduler.snapshot_active") == 0 );
t( sp_getint(env, "scheduler.snapshot_ssn") == 0 );
t( sp_getint(env, "scheduler.snapshot_ssn_last") == 0 );
t( sp_setint(env, "scheduler.snapshot", 0) == 0 );
t( sp_getint(env, "scheduler.snapshot_active") == 1 );
t( sp_getint(env, "scheduler.snapshot_ssn") == 1 );
t( sp_getint(env, "scheduler.snapshot_ssn_last") == 0 );
t( sp_setint(env, "scheduler.run", 0) == 1 );
t( sp_setint(env, "scheduler.run", 0) == 1 );
t( sp_setint(env, "scheduler.run", 0) == 0 );
t( sp_getint(env, "scheduler.snapshot_active") == 0 );
t( sp_getint(env, "scheduler.snapshot_ssn") == 0 );
t( sp_getint(env, "scheduler.snapshot_ssn_last") == 1 );
while (key < 15) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_destroy(env) == 0 );
env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
db = sp_getobject(env, "db.test");
t( sp_open(env) == 0 );
key = 0;
while (key < 10) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
o = sp_get(db, o);
t( o != NULL );
sp_destroy(o);
key++;
}
t( sp_destroy(env) == 0 );
}
示例5: main
int main()
{
srand(time(NULL));
int i;
UserData ud;
ud.pdel = 0;
sp_data *sp;
sp_create(&sp);
sp->len = 44100 * 40;
char *notes[] = {
"62 69 78",
"55 62 69 71",
"43 50"
};
for(i = 0; i < NUMLINE; i++) {
sp_randi_create(&ud.line[i].randi);
chord_cloud_create(&ud.line[i].cc);
chord_cloud_init(sp, ud.line[i].cc, notes[i], 0.1);
sp_randi_init(sp, ud.line[i].randi, rand());
ud.line[i].randi->cps = 0.1 + randf(1.5);
}
sp_revsc_create(&ud.rev);
sp_revsc_init(sp, ud.rev);
ud.rev->feedback = 0.95;
sp_metro_create(&ud.clk);
sp_metro_init(sp, ud.clk);
ud.clk->freq = 86.0 / 60.0;
sp_count_create(&ud.meter);
sp_count_init(sp, ud.meter);
ud.meter->count = 5;
sp_drip_create(&ud.drip);
sp_drip_init(sp, ud.drip, 0.01);
sp_vdelay_create(&ud.del);
/* give some headroom for the delay */
sp_vdelay_init(sp, ud.del, 0.4);
ud.del->del = 0.3;
sp_tenv_create(&ud.master);
sp_tenv_init(sp, ud.master);
ud.master->atk = 0;
ud.master->hold = 30;
ud.master->rel = 10;
sp_progress_create(&ud.prog);
sp_progress_init(sp, ud.prog);
modal_create(&ud.mod);
modal_init(sp, ud.mod);
sp_ftbl_create(sp, &ud.notes, 1);
sp_gen_vals(sp, ud.notes, "62 64 59 57");
sp_tseq_create(&ud.seq);
sp_tseq_init(sp, ud.seq, ud.notes);
sp_maygate_create(&ud.mg);
sp_maygate_init(sp, ud.mg);
ud.mg->prob = 0.3;
ud.mg->mode = 1;
sp_process(sp, &ud, process);
for(i = 0; i < NUMLINE; i++) {
sp_randi_destroy(&ud.line[i].randi);
chord_cloud_destroy(&ud.line[i].cc);
}
sp_drip_destroy(&ud.drip);
sp_revsc_destroy(&ud.rev);
sp_metro_destroy(&ud.clk);
sp_count_destroy(&ud.meter);
sp_vdelay_destroy(&ud.del);
sp_tenv_destroy(&ud.master);
modal_destroy(&ud.mod);
sp_ftbl_destroy(&ud.notes);
sp_tseq_destroy(&ud.seq);
sp_maygate_destroy(&ud.mg);
sp_progress_destroy(&ud.prog);
sp_destroy(&sp);
return 0;
}
示例6: recover_loop
static void
recover_loop(stc *cx)
{
int seedprev = -1;
int seed = 3424118;
int seedorigin = seed;
int run = 10;
int count = 1040;
while (run >= 0) {
cx->env = sp_env();
t( cx->env != NULL );
void *c = sp_ctl(cx->env);
t( c != NULL );
t( sp_set(c, "sham.path", cx->suite->shamdir) == 0 );
t( sp_set(c, "scheduler.threads", "0") == 0 );
t( sp_set(c, "compaction.0.branch_wm", "1") == 0 );
t( sp_set(c, "log.path", cx->suite->logdir) == 0 );
t( sp_set(c, "log.sync", "0") == 0 );
t( sp_set(c, "log.rotate_sync", "0") == 0 );
t( sp_set(c, "db", "test") == 0 );
t( sp_set(c, "db.test.path", cx->suite->dir) == 0 );
t( sp_set(c, "db.test.sync", "0") == 0 );
t( sp_set(c, "db.test.index.cmp", "u32", NULL) == 0 );
cx->db = sp_get(c, "db.test");
t( cx->db != NULL );
t( sp_open(cx->env) == 0 );
int i = 0;
if (seedprev != -1) {
srand(seedprev);
while (i < count) {
int k = rand();
void *o = sp_object(cx->db);
t( sp_set(o, "key", &k, sizeof(k)) == 0 );
o = sp_get(cx->db, o);
t( o != NULL );
st_transaction(cx);
t( *(int*)sp_get(o, "value", NULL) == k );
sp_destroy(o);
i++;
}
t( sp_set(c, "db.test.branch") == 0 );
}
srand(seed);
i = 0;
while (i < count) {
int k = rand();
void *o = sp_object(cx->db);
t( o != NULL );
t( sp_set(o, "key", &k, sizeof(k)) == 0 );
t( sp_set(o, "value", &k, sizeof(k)) == 0 );
t( sp_set(cx->db, o) == 0 );
st_transaction(cx);
i++;
}
t( sp_destroy(cx->env) == 0 );
seedprev = seed;
seed = time(NULL);
run--;
}
cx->env = sp_env();
t( cx->env != NULL );
void *c = sp_ctl(cx->env);
t( c != NULL );
t( sp_set(c, "sham.path", cx->suite->shamdir) == 0 );
t( sp_set(c, "scheduler.threads", "0") == 0 );
t( sp_set(c, "compaction.0.branch_wm", "1") == 0 );
t( sp_set(c, "log.path", cx->suite->logdir) == 0 );
t( sp_set(c, "log.sync", "0") == 0 );
t( sp_set(c, "log.rotate_sync", "0") == 0 );
t( sp_set(c, "db", "test") == 0 );
t( sp_set(c, "db.test.path", cx->suite->dir) == 0 );
t( sp_set(c, "db.test.sync", "0") == 0 );
t( sp_set(c, "db.test.index.cmp", "u32", NULL) == 0 );
cx->db = sp_get(c, "db.test");
t( cx->db != NULL );
t( sp_open(cx->env) == 0 );
srand(seedorigin);
int i = 0;
while (i < count) {
int k = rand();
void *o = sp_object(cx->db);
t( sp_set(o, "key", &k, sizeof(k)) == 0 );
o = sp_get(cx->db, o);
t( o != NULL );
t( *(int*)sp_get(o, "value", NULL) == k );
sp_destroy(o);
i++;
}
t( sp_destroy(cx->env) == 0 );
cx->env = NULL;
cx->db = NULL;
}
示例7: destroy
void destroy() {
plumber_clean(&pd);
sp_destroy(&sp);
}
示例8: destroy
void destroy() {
sp_noise_destroy(&noise);
sp_destroy(&sp);
}
示例9: destroy
void destroy() {
sp_autowah_destroy(&autowah);
sp_destroy(&sp);
}
示例10: destroy
void destroy() {
sp_osc_destroy(&osc);
sp_destroy(&sp);
}
示例11: destroy
void destroy() {
sp_drip_destroy(&drip);
sp_destroy(&sp);
}
示例12: sphia_iterator_free
void
sphia_iterator_free (sphia_iterator_t *self) {
if (self->cursor) sp_destroy(self->cursor);
free(self);
}
示例13: sphia_iterator_end
void
sphia_iterator_end (sphia_iterator_t *self) {
if (self->cursor) sp_destroy(self->cursor);
self->cursor = NULL;
}
示例14: tpr_test1
static void
tpr_test1(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.enable", 0) == 0 );
t( sp_setint(env, "log.two_phase_recover", 1) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(db) == 0 );
t( sp_open(env) == 0 );
int key = 7;
int value = 8;
void *o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
t( sp_setint(env, "db.test.branch", 0) == 0 );
key = 7;
value = 9;
o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
t( sp_destroy(env) == 0 );
env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.enable", 0) == 0 );
t( sp_setint(env, "log.two_phase_recover", 1) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(db) == 0 );
char *v = sp_getstring(env, "db.test.status", NULL);
t( strcmp(v, "recover") == 0 );
free(v);
void *tx = sp_begin(env);
t( tx != NULL );
key = 7;
value = 8;
o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(tx, o) == 0 );
t( sp_setint(tx, "lsn", 1) == 0 );
t( sp_commit(tx) == 0 ); /* skip */
tx = sp_begin(env);
t( tx != NULL );
key = 7;
value = 9;
o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(tx, o) == 0 );
t( sp_setint(tx, "lsn", 2) == 0 );
t( sp_commit(tx) == 0 ); /* commit */
t( sp_open(env) == 0 );
v = sp_getstring(env, "db.test.status", NULL);
t( strcmp(v, "online") == 0 );
free(v);
o = sp_object(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
o = sp_get(db, o);
t( o != NULL );
t( *(int*)sp_getstring(o, "value", NULL) == 9 );
t( sp_getint(o, "lsn") == 2ULL );
t( sp_destroy(o) == 0 );
//.........这里部分代码省略.........
示例15: destroy
void destroy() {
sp_tbvcf_destroy(&tbvcf);
sp_destroy(&sp);
}