backlog: early work to have memory accounting of the backlogs

This commit is contained in:
Boris Faure 2019-11-23 23:06:34 +01:00
parent 62302496dc
commit 0c87de9f5e
Signed by untrusted user who does not match committer: borisfaure
GPG Key ID: EAA9CD729F522998
1 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,15 @@ static int ts_uncomp = 0;
static int ts_freeops = 0;
static Eina_List *ptys = NULL;
static int64_t mem_used = 0;
static void
_accounting_change(int64_t diff)
{
mem_used += diff;
}
void
termpty_save_register(Termpty *ty)
{
@ -41,6 +50,7 @@ termpty_save_new(Termpty *ty, Termsave *ts, int w)
if (!cells ) return NULL;
ts->cells = cells;
ts->w = w;
_accounting_change(w * sizeof(Termcell));
return ts;
}
@ -57,7 +67,9 @@ termpty_save_expand(Termpty *ty, Termsave *ts, Termcell *cells, size_t delta)
0, delta * sizeof(Termcell));
TERMPTY_CELL_COPY(ty, cells, &newcells[ts->w], (int)delta);
_accounting_change(-1 * ts->w * sizeof(Termcell));
ts->w += delta;
_accounting_change(ts->w * sizeof(Termcell));
ts->cells = newcells;
return ts;
}
@ -77,6 +89,7 @@ termpty_save_free(Termpty *ty, Termsave *ts)
}
free(ts->cells);
ts->cells = NULL;
_accounting_change(-1 * ts->w * sizeof(Termcell));
ts->w = 0;
}