mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 10:21:31 +03:00
jets: start trying to clean up memory leaks.
This cleans up memory leaks in the %ud/%da parsers/renderers, while disabling everything else. There looks like there's a lot of leaks in the +ob core.
This commit is contained in:
parent
e097bdda58
commit
1eb2e58bb7
@ -5,7 +5,9 @@
|
|||||||
/** Tier 1.
|
/** Tier 1.
|
||||||
**/
|
**/
|
||||||
u3_noun u3ka_add(u3_noun a, u3_noun b);
|
u3_noun u3ka_add(u3_noun a, u3_noun b);
|
||||||
|
u3_noun u3ka_div(u3_noun a, u3_noun b);
|
||||||
u3_noun u3ka_sub(u3_noun a, u3_noun b);
|
u3_noun u3ka_sub(u3_noun a, u3_noun b);
|
||||||
|
u3_noun u3ka_mod(u3_noun a, u3_noun b);
|
||||||
u3_noun u3ka_mul(u3_noun a, u3_noun b);
|
u3_noun u3ka_mul(u3_noun a, u3_noun b);
|
||||||
u3_noun u3ka_gth(u3_noun a, u3_noun b);
|
u3_noun u3ka_gth(u3_noun a, u3_noun b);
|
||||||
u3_noun u3ka_lte(u3_noun a, u3_noun b);
|
u3_noun u3ka_lte(u3_noun a, u3_noun b);
|
||||||
@ -18,6 +20,10 @@
|
|||||||
|
|
||||||
/* u3kc: tier 3 functions
|
/* u3kc: tier 3 functions
|
||||||
*/
|
*/
|
||||||
|
u3_noun
|
||||||
|
u3kc_con(u3_noun a,
|
||||||
|
u3_noun b);
|
||||||
|
|
||||||
/* u3kc_mix(): binary xor.
|
/* u3kc_mix(): binary xor.
|
||||||
*/
|
*/
|
||||||
u3_noun
|
u3_noun
|
||||||
|
@ -44,3 +44,13 @@
|
|||||||
return u3qa_div(a, b);
|
return u3qa_div(a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3ka_div(u3_noun a,
|
||||||
|
u3_noun b)
|
||||||
|
{
|
||||||
|
u3_noun c = u3qa_div(a, b);
|
||||||
|
u3z(a); u3z(b);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
@ -41,3 +41,12 @@
|
|||||||
return u3qa_mod(a, b);
|
return u3qa_mod(a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3ka_mod(u3_noun a,
|
||||||
|
u3_noun b)
|
||||||
|
{
|
||||||
|
u3_noun c = u3qa_mod(a, b);
|
||||||
|
u3z(a); u3z(b);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
@ -49,3 +49,12 @@
|
|||||||
return u3qc_con(a, b);
|
return u3qc_con(a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3kc_con(u3_noun a,
|
||||||
|
u3_noun b)
|
||||||
|
{
|
||||||
|
u3_noun c = u3qc_con(a, b);
|
||||||
|
u3z(a); u3z(b);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
@ -55,7 +55,9 @@ static
|
|||||||
u3_noun
|
u3_noun
|
||||||
_print_da(u3_atom cor, u3_atom raw_da)
|
_print_da(u3_atom cor, u3_atom raw_da)
|
||||||
{
|
{
|
||||||
|
u3l_log("about to cook");
|
||||||
u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore");
|
u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore");
|
||||||
|
u3l_log("cooked");
|
||||||
u3_noun yod = u3n_slam_on(hok, u3k(raw_da));
|
u3_noun yod = u3n_slam_on(hok, u3k(raw_da));
|
||||||
|
|
||||||
u3_noun out = 0;
|
u3_noun out = 0;
|
||||||
@ -221,14 +223,17 @@ _print_ud(u3_atom ud)
|
|||||||
int between = 0;
|
int between = 0;
|
||||||
u3_atom list = 0;
|
u3_atom list = 0;
|
||||||
|
|
||||||
|
u3k(ud);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (between == 3) {
|
if (between == 3) {
|
||||||
list = u3nc('.', list);
|
list = u3nc('.', list);
|
||||||
between = 0;
|
between = 0;
|
||||||
}
|
}
|
||||||
list = u3nc(u3qa_add(u3qa_mod(u3k(ud), 10), '0'), list);
|
|
||||||
|
list = u3nc(u3ka_add(u3ka_mod(ud, 10), '0'), list);
|
||||||
between++;
|
between++;
|
||||||
ud = u3qa_div(ud, 10);
|
ud = u3ka_div(ud, 10);
|
||||||
} while (c3n == u3r_sing(ud, 0));
|
} while (c3n == u3r_sing(ud, 0));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -252,8 +257,8 @@ u3we_scow(u3_noun cor)
|
|||||||
case c3__da:
|
case c3__da:
|
||||||
return _print_da(cor, atom);
|
return _print_da(cor, atom);
|
||||||
|
|
||||||
case 'p':
|
/* case 'p': */
|
||||||
return _print_p(atom);
|
/* return _print_p(atom); */
|
||||||
|
|
||||||
case c3__ud:
|
case c3__ud:
|
||||||
return _print_ud(atom);
|
return _print_ud(atom);
|
||||||
@ -271,6 +276,7 @@ u3we_scow(u3_noun cor)
|
|||||||
u3_noun
|
u3_noun
|
||||||
u3we_scot(u3_noun cor)
|
u3we_scot(u3_noun cor)
|
||||||
{
|
{
|
||||||
|
/* u3l_log("u3we_scot"); */
|
||||||
u3_noun mod;
|
u3_noun mod;
|
||||||
u3_noun atom;
|
u3_noun atom;
|
||||||
|
|
||||||
@ -292,11 +298,15 @@ u3we_scot(u3_noun cor)
|
|||||||
/* return u3qc_rap(3, x); */
|
/* return u3qc_rap(3, x); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
case 'p':
|
/* case 'p': */
|
||||||
return u3qc_rap(3, _print_p(atom));
|
/* return u3qc_rap(3, _print_p(atom)); */
|
||||||
|
|
||||||
case c3__ud:
|
case c3__ud: {
|
||||||
return u3qc_rap(3, _print_ud(atom));
|
u3_atom tape = _print_ud(atom);
|
||||||
|
u3_atom ret = u3qc_rap(3, tape);
|
||||||
|
u3z(tape);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return u3_none;
|
return u3_none;
|
||||||
|
@ -307,8 +307,8 @@ _parse_p(u3_noun txt) {
|
|||||||
numname = cur[0] - '0'; \
|
numname = cur[0] - '0'; \
|
||||||
cur++; \
|
cur++; \
|
||||||
while (isdigit(cur[0])) { \
|
while (isdigit(cur[0])) { \
|
||||||
numname = u3qa_mul(numname, 10); \
|
numname = u3ka_mul(numname, 10); \
|
||||||
numname = u3qa_add(numname, cur[0] - '0'); \
|
numname = u3ka_add(numname, cur[0] - '0'); \
|
||||||
cur++; \
|
cur++; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -323,8 +323,8 @@ _parse_p(u3_noun txt) {
|
|||||||
numname = cur[0] - '0'; \
|
numname = cur[0] - '0'; \
|
||||||
cur++; \
|
cur++; \
|
||||||
while (isdigit(cur[0])) { \
|
while (isdigit(cur[0])) { \
|
||||||
numname = u3qa_mul(numname, 10); \
|
numname = u3ka_mul(numname, 10); \
|
||||||
numname = u3qa_add(numname, cur[0] - '0'); \
|
numname = u3ka_add(numname, cur[0] - '0'); \
|
||||||
cur++; \
|
cur++; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -435,13 +435,15 @@ _parse_da(u3_noun cor, u3_noun txt) {
|
|||||||
|
|
||||||
if (cur[0] == 0) {
|
if (cur[0] == 0) {
|
||||||
c3_free(c);
|
c3_free(c);
|
||||||
list = u3qb_flop(list);
|
|
||||||
|
u3_noun flopped = u3qb_flop(list);
|
||||||
|
u3z(list);
|
||||||
|
|
||||||
u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year");
|
u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year");
|
||||||
u3_noun res = u3n_slam_on(hok,
|
u3_noun res = u3n_slam_on(hok,
|
||||||
u3nt(u3nc(bc, year), month,
|
u3nt(u3nc(bc, year), month,
|
||||||
u3nc(day,
|
u3nc(day,
|
||||||
u3nq(hour, minute, second, list))));
|
u3nq(hour, minute, second, flopped))));
|
||||||
return u3nc(0, res);
|
return u3nc(0, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,8 +500,8 @@ u3we_slaw(u3_noun cor)
|
|||||||
case c3__da:
|
case c3__da:
|
||||||
return _parse_da(cor, txt);
|
return _parse_da(cor, txt);
|
||||||
|
|
||||||
case 'p':
|
/* case 'p': */
|
||||||
return _parse_p(txt);
|
/* return _parse_p(txt); */
|
||||||
|
|
||||||
case c3__ud:
|
case c3__ud:
|
||||||
return _parse_ud(txt);
|
return _parse_ud(txt);
|
||||||
|
@ -1298,7 +1298,7 @@ static c3_c* _141_tri_shal_ha[] = {
|
|||||||
|
|
||||||
static u3j_core _141_tri_d[] =
|
static u3j_core _141_tri_d[] =
|
||||||
{ { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho },
|
{ { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho },
|
||||||
{ "ob", 3, 0, _141_tri__ob_d, 0 },
|
// { "ob", 3, 0, _141_tri__ob_d, 0 },
|
||||||
{ "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha },
|
{ "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha },
|
||||||
{ "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha },
|
{ "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha },
|
||||||
{ "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha },
|
{ "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha },
|
||||||
|
Loading…
Reference in New Issue
Block a user