int si_plannerfree(siplanner *p, ssa *a) { ss_rqfree(&p->compact, a); ss_rqfree(&p->branch, a); ss_rqfree(&p->temp, a); return 0; }
static void ss_rq_test8(void) { ssa a; ss_aopen(&a, &ss_stda); ssrq q; t( ss_rqinit(&q, &a, 10, 100) == 0 ); ssrqnode *an = ss_malloc(&a, sizeof(ssrqnode)); ssrqnode *bn = ss_malloc(&a, sizeof(ssrqnode)); ssrqnode *cn = ss_malloc(&a, sizeof(ssrqnode)); ssrqnode *dn = ss_malloc(&a, sizeof(ssrqnode)); t( an != NULL ); t( bn != NULL ); t( cn != NULL ); t( dn != NULL ); ss_rqinitnode(an); ss_rqinitnode(bn); ss_rqinitnode(cn); ss_rqinitnode(dn); ss_rqadd(&q, an, 0); ss_rqadd(&q, bn, 10); ss_rqadd(&q, cn, 20); ss_rqadd(&q, dn, 30); int i = 30; ssrqnode *n = NULL; while ((n = ss_rqprev(&q, n))) i -= 10; ss_rqfree(&q, &a); ss_free(&a, an); ss_free(&a, bn); ss_free(&a, cn); ss_free(&a, dn); }
static void ss_rq_test3(void) { ssa a; ss_aopen(&a, &ss_stda); ssrq q; t( ss_rqinit(&q, &a, 1, 10) == 0 ); ssrqnode *an = ss_malloc(&a, sizeof(ssrqnode)); ssrqnode *bn = ss_malloc(&a, sizeof(ssrqnode)); ssrqnode *cn = ss_malloc(&a, sizeof(ssrqnode)); t( an != NULL ); t( bn != NULL ); t( cn != NULL ); ss_rqinitnode(an); ss_rqinitnode(bn); ss_rqinitnode(cn); ss_rqadd(&q, an, 1); ss_rqadd(&q, bn, 2); ss_rqdelete(&q, bn); ss_rqadd(&q, cn, 3); int i = 3; ssrqnode *n = NULL; while ((n = ss_rqprev(&q, n))) { t( i == n->v ); i = 1; } ss_rqfree(&q, &a); ss_free(&a, an); ss_free(&a, bn); ss_free(&a, cn); }
static void ss_rq_test0(void) { ssa a; ss_aopen(&a, &ss_stda); ssrq q; t( ss_rqinit(&q, &a, 1, 10) == 0 ); ss_rqfree(&q, &a); }
int si_plannerinit(siplanner *p, ssa *a, void *i) { int rc = ss_rqinit(&p->compact, a, 1, 20); if (ssunlikely(rc == -1)) return -1; /* 1Mb step up to 4Gb */ rc = ss_rqinit(&p->branch, a, 1024 * 1024, 4000); if (ssunlikely(rc == -1)) { ss_rqfree(&p->compact, a); return -1; } rc = ss_rqinit(&p->temp, a, 1, 100); if (ssunlikely(rc == -1)) { ss_rqfree(&p->compact, a); ss_rqfree(&p->branch, a); return -1; } p->i = i; return 0; }