vere: adds u3_ovum init/dispose to ward.c

This commit is contained in:
Joe Bryan 2020-06-19 11:05:57 -07:00
parent 5d71e0a804
commit b75d42c335
4 changed files with 76 additions and 40 deletions

View File

@ -744,6 +744,20 @@
void
u3_gift_free(u3_gift* gif_u);
/* u3_ovum_init: initialize an unlinked potential event
*/
u3_ovum*
u3_ovum_init(u3_auto* car_u,
c3_l msc_l,
u3_noun tar,
u3_noun wir,
u3_noun cad);
/* u3_ovum_free: dispose an unlinked potential event
*/
void
u3_ovum_free(u3_ovum *egg_u);
/** New vere
**/
/* u3_auto_init(): initialize all drivers.

View File

@ -28,21 +28,7 @@ u3_auto_plan(u3_auto* car_u,
u3_noun wir,
u3_noun cad)
{
u3_ovum* egg_u = c3_malloc(sizeof(*egg_u));
egg_u->car_u = car_u;
egg_u->vod_p = 0;
egg_u->msc_l = msc_l;
egg_u->tar = tar;
egg_u->wir = wir;
egg_u->cad = cad;
// spinner defaults
//
egg_u->pin_u.lab = u3k(u3h(wir));
egg_u->pin_u.del_o = c3y;
egg_u->cb_u.news_f = 0;
egg_u->cb_u.bail_f = 0;
u3_ovum *egg_u = u3_ovum_init(car_u, msc_l, tar, wir, cad);
if ( !car_u->ent_u ) {
c3_assert(!car_u->ext_u);
@ -114,9 +100,7 @@ u3_auto_bail(u3_ovum* egg_u, u3_noun lud)
u3_auto_bail_slog(egg_u, lud);
}
// XX confirm
//
u3_auto_drop(0, egg_u);
u3_ovum_free(egg_u);
}
/* _auto_news(): notify driver of ovum status
@ -139,11 +123,7 @@ void
u3_auto_done(u3_ovum* egg_u)
{
_auto_news(egg_u, u3_ovum_done);
// XX confirm
//
u3_auto_drop(0, egg_u);
//
u3_ovum_free(egg_u);
}
/* u3_auto_work(): notify driver of [egg_u] commencement.
@ -181,11 +161,7 @@ u3_auto_drop(u3_auto* car_u, u3_ovum* egg_u)
_auto_news(egg_u, u3_ovum_drop);
}
u3z(egg_u->pin_u.lab);
u3z(egg_u->tar);
u3z(egg_u->wir);
u3z(egg_u->cad);
c3_free(egg_u);
u3_ovum_free(egg_u);
}
/* u3_auto_next(): select an ovum, dequeue and construct.
@ -329,9 +305,16 @@ u3_auto_exit(u3_auto* car_u)
while ( car_u ) {
nex_u = car_u->nex_u;
// while ( car_u->ext_u ) {
// u3_auto_drop(car_u, car_u->ext_u);
// }
{
u3_ovum *egg_u = car_u->ext_u;
u3_ovum *xen_u;
while ( egg_u ) {
xen_u = egg_u->nex_u;
u3_ovum_free(egg_u);
egg_u = xen_u;
}
}
cod_l = u3a_lush(car_u->nam_m);
car_u->io.exit_f(car_u);

View File

@ -447,9 +447,8 @@ _lord_plea_work_swap(u3_lord* god_u, u3_ovum* egg_u, u3_noun dat)
|| (c3n == u3r_safe_word(mug, &mug_l))
|| (c3n == u3a_is_cell(job)) )
{
// XX dispose egg_u
//
u3z(job);
u3_ovum_free(egg_u);
fprintf(stderr, "lord: invalid %%work\r\n");
return _lord_plea_foul(god_u, c3__swap, dat);
}
@ -476,9 +475,8 @@ _lord_plea_work_done(u3_lord* god_u,
|| (c3n == u3r_safe_chub(eve, &eve_d))
|| (c3n == u3r_safe_word(mug, &mug_l)) )
{
// XX dispose egg_u
//
u3z(job);
u3_ovum_free(egg_u);
fprintf(stderr, "lord: invalid %%work\r\n");
return _lord_plea_foul(god_u, c3__done, dat);
}
@ -505,17 +503,15 @@ _lord_plea_work(u3_lord* god_u, u3_noun dat)
}
if ( c3n == u3a_is_cell(dat) ) {
// XX dispose egg_u
//
u3z(job);
u3_ovum_free(egg_u);
return _lord_plea_foul(god_u, c3__work, dat);
}
switch ( u3h(dat) ) {
default: {
// XX dispose egg_u
//
u3z(job);
u3_ovum_free(egg_u);
return _lord_plea_foul(god_u, c3__work, dat);
} break;

View File

@ -119,8 +119,51 @@ u3_gift_init(c3_d eve_d, u3_noun act)
/* u3_gift_free(): dispose effect list.
*/
void
u3_gift_free(u3_gift* gif_u)
u3_gift_free(u3_gift *gif_u)
{
u3z(gif_u->act);
c3_free(gif_u);
}
/* u3_ovum_init: initialize an unlinked potential event
*/
u3_ovum*
u3_ovum_init(u3_auto* car_u,
c3_l msc_l,
u3_noun tar,
u3_noun wir,
u3_noun cad)
{
u3_ovum* egg_u = c3_malloc(sizeof(*egg_u));
egg_u->car_u = car_u;
egg_u->vod_p = 0;
egg_u->msc_l = msc_l;
egg_u->tar = tar;
egg_u->wir = wir;
egg_u->cad = cad;
egg_u->pre_u = egg_u->nex_u = 0;
egg_u->cb_u.news_f = 0;
egg_u->cb_u.bail_f = 0;
// spinner defaults
//
egg_u->pin_u.lab = u3k(u3h(wir));
egg_u->pin_u.del_o = c3y;
return egg_u;
}
/* u3_ovum_free: dispose an unlinked potential event
*/
void
u3_ovum_free(u3_ovum *egg_u)
{
u3z(egg_u->pin_u.lab);
u3z(egg_u->tar);
u3z(egg_u->wir);
u3z(egg_u->cad);
c3_free(egg_u);
}