mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 10:02:47 +03:00
vere: move u3_pico lifecycle functions into ward.c
Now we free the struct _and its nouns_ in the same place, rather than transferring the nouns into lord.c, but still freeing the struct locally. This means the lord needs to explicitly retain the nouns in the u3_pico.
This commit is contained in:
parent
25a4806439
commit
f8601d9a6a
@ -793,6 +793,16 @@
|
||||
void
|
||||
u3_ovum_free(u3_ovum *egg_u);
|
||||
|
||||
/* u3_pico_init(): initialize a scry request struct
|
||||
*/
|
||||
u3_pico*
|
||||
u3_pico_init();
|
||||
|
||||
/* u3_pico_free(): dispose a scry request struct
|
||||
*/
|
||||
void
|
||||
u3_pico_free(u3_pico* pic_u);
|
||||
|
||||
/* u3_mcut_char(): measure/cut character.
|
||||
*/
|
||||
c3_w
|
||||
|
@ -815,7 +815,7 @@ u3_lord_peek_pico(u3_lord* god_u,
|
||||
wit_u->pek_u->ptr_v = pic_u->ptr_v;
|
||||
wit_u->pek_u->fun_f = pic_u->fun_f;
|
||||
wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u);
|
||||
wit_u->pek_u->gan = pic_u->gan;
|
||||
wit_u->pek_u->gan = u3k(pic_u->gan);
|
||||
|
||||
// construct the full scry path
|
||||
//
|
||||
@ -823,7 +823,7 @@ u3_lord_peek_pico(u3_lord* god_u,
|
||||
default: c3_assert(0);
|
||||
|
||||
case u3_pico_full: {
|
||||
wit_u->pek_u->ful = pic_u->ful;
|
||||
wit_u->pek_u->ful = u3k(pic_u->ful);
|
||||
} break;
|
||||
|
||||
case u3_pico_mine: {
|
||||
@ -831,7 +831,7 @@ u3_lord_peek_pico(u3_lord* god_u,
|
||||
//
|
||||
u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better
|
||||
u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d));
|
||||
wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, pic_u->min_u.pax);
|
||||
wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, u3k(pic_u->min_u.pax));
|
||||
} break;
|
||||
|
||||
case u3_pico_last: {
|
||||
@ -843,9 +843,9 @@ u3_lord_peek_pico(u3_lord* god_u,
|
||||
|
||||
wit_u->pek_u->ful = u3nc(pic_u->las_u.car_m,
|
||||
u3nq(our,
|
||||
pic_u->las_u.des,
|
||||
u3k(pic_u->las_u.des),
|
||||
cas,
|
||||
pic_u->las_u.pax));
|
||||
u3k(pic_u->las_u.pax)));
|
||||
} break;
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,11 @@
|
||||
|
||||
#undef VERBOSE_PIER
|
||||
|
||||
/* _pier_peek_new(): add a new u3_pico to the peek queue
|
||||
/* _pier_peek_plan(): add a u3_pico to the peek queue
|
||||
*/
|
||||
static u3_pico*
|
||||
_pier_peek_new(u3_pier* pir_u)
|
||||
static void
|
||||
_pier_peek_plan(u3_pier* pir_u, u3_pico* pic_u)
|
||||
{
|
||||
u3_pico* pic_u = c3_calloc(sizeof(*pic_u));
|
||||
|
||||
if (!pir_u->pec_u.ent_u) {
|
||||
c3_assert( !pir_u->pec_u.ext_u );
|
||||
pir_u->pec_u.ent_u = pir_u->pec_u.ext_u = pic_u;
|
||||
@ -42,7 +40,7 @@ _pier_peek_new(u3_pier* pir_u)
|
||||
pir_u->pec_u.ent_u = pic_u;
|
||||
}
|
||||
|
||||
return pic_u;
|
||||
u3_pier_spin(pir_u);
|
||||
}
|
||||
|
||||
/* _pier_peek_next(): pop u3_pico off of peek queue
|
||||
@ -114,7 +112,7 @@ _pier_work_send(u3_work* wok_u)
|
||||
{
|
||||
len_w--;
|
||||
u3_lord_peek_pico(god_u, pic_u);
|
||||
c3_free(pic_u);
|
||||
u3_pico_free(pic_u);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +121,7 @@ _pier_work_send(u3_work* wok_u)
|
||||
while ( len_w-- && (pic_u = _pier_peek_next(pir_u)) )
|
||||
{
|
||||
u3_lord_peek_pico(god_u, pic_u);
|
||||
c3_free(pic_u);
|
||||
u3_pico_free(pic_u);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -419,7 +417,7 @@ u3_pier_peek(u3_pier* pir_u,
|
||||
void* ptr_v,
|
||||
u3_peek_cb fun_f)
|
||||
{
|
||||
u3_pico* pic_u = _pier_peek_new(pir_u);
|
||||
u3_pico* pic_u = u3_pico_init();
|
||||
|
||||
pic_u->ptr_v = ptr_v;
|
||||
pic_u->fun_f = fun_f;
|
||||
@ -428,7 +426,7 @@ u3_pier_peek(u3_pier* pir_u,
|
||||
pic_u->typ_e = u3_pico_full;
|
||||
pic_u->ful = ful;
|
||||
|
||||
u3_pier_spin(pir_u);
|
||||
_pier_peek_plan(pir_u, pic_u);
|
||||
}
|
||||
|
||||
/* u3_pier_peek_mine(): read namespace, injecting ship.
|
||||
@ -441,7 +439,7 @@ u3_pier_peek_mine(u3_pier* pir_u,
|
||||
void* ptr_v,
|
||||
u3_peek_cb fun_f)
|
||||
{
|
||||
u3_pico* pic_u = _pier_peek_new(pir_u);
|
||||
u3_pico* pic_u = u3_pico_init();
|
||||
|
||||
pic_u->ptr_v = ptr_v;
|
||||
pic_u->fun_f = fun_f;
|
||||
@ -451,7 +449,7 @@ u3_pier_peek_mine(u3_pier* pir_u,
|
||||
pic_u->min_u.car_m = car_m;
|
||||
pic_u->min_u.pax = pax;
|
||||
|
||||
u3_pier_spin(pir_u);
|
||||
_pier_peek_plan(pir_u, pic_u);
|
||||
}
|
||||
|
||||
/* u3_pier_peek_last(): read namespace, injecting ship and case.
|
||||
@ -465,7 +463,7 @@ u3_pier_peek_last(u3_pier* pir_u,
|
||||
void* ptr_v,
|
||||
u3_peek_cb fun_f)
|
||||
{
|
||||
u3_pico* pic_u = _pier_peek_new(pir_u);
|
||||
u3_pico* pic_u = u3_pico_init();
|
||||
|
||||
pic_u->ptr_v = ptr_v;
|
||||
pic_u->fun_f = fun_f;
|
||||
@ -476,7 +474,7 @@ u3_pier_peek_last(u3_pier* pir_u,
|
||||
pic_u->las_u.des = des;
|
||||
pic_u->las_u.pax = pax;
|
||||
|
||||
u3_pier_spin(pir_u);
|
||||
_pier_peek_plan(pir_u, pic_u);
|
||||
}
|
||||
|
||||
/* _pier_work_init(): begin processing new events
|
||||
|
@ -168,6 +168,42 @@ u3_ovum_free(u3_ovum *egg_u)
|
||||
c3_free(egg_u);
|
||||
}
|
||||
|
||||
/* u3_pico_init(): initialize a scry request struct
|
||||
*/
|
||||
u3_pico*
|
||||
u3_pico_init()
|
||||
{
|
||||
u3_pico* pic_u = c3_calloc(sizeof(*pic_u));
|
||||
return pic_u;
|
||||
}
|
||||
|
||||
/* u3_pico_free(): dispose a scry request struct
|
||||
*/
|
||||
void
|
||||
u3_pico_free(u3_pico* pic_u)
|
||||
{
|
||||
u3z(pic_u->gan);
|
||||
|
||||
switch ( pic_u->typ_e ) {
|
||||
default: c3_assert(0);
|
||||
|
||||
case u3_pico_full: {
|
||||
u3z(pic_u->ful);
|
||||
} break;
|
||||
|
||||
case u3_pico_mine: {
|
||||
u3z(pic_u->min_u.pax);
|
||||
} break;
|
||||
|
||||
case u3_pico_last: {
|
||||
u3z(pic_u->las_u.des);
|
||||
u3z(pic_u->las_u.pax);
|
||||
} break;
|
||||
}
|
||||
|
||||
c3_free(pic_u);
|
||||
}
|
||||
|
||||
/* u3_mcut_char(): measure/cut character.
|
||||
*/
|
||||
c3_w
|
||||
|
Loading…
Reference in New Issue
Block a user