mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-08 10:06:22 -05:00
term: no need to stack-allocate an array of worker contexts
This commit is contained in:
parent
8e6f87eb17
commit
4ec9db8e18
1 changed files with 9 additions and 6 deletions
15
terminal.c
15
terminal.c
|
|
@ -219,7 +219,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
|||
int delay_upper_fd = -1;
|
||||
|
||||
struct terminal *term = NULL;
|
||||
struct render_worker_context *worker_context[conf->render_worker_count];
|
||||
|
||||
if ((ptmx = posix_openpt(O_RDWR | O_NOCTTY)) == -1) {
|
||||
LOG_ERRNO("failed to open PTY");
|
||||
|
|
@ -341,12 +340,16 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
|||
mtx_init(&term->render.workers.lock, mtx_plain);
|
||||
cnd_init(&term->render.workers.cond);
|
||||
|
||||
term->render.workers.threads = calloc(term->render.workers.count, sizeof(term->render.workers.threads[0]));
|
||||
term->render.workers.threads = calloc(
|
||||
term->render.workers.count, sizeof(term->render.workers.threads[0]));
|
||||
|
||||
for (size_t i = 0; i < term->render.workers.count; i++) {
|
||||
worker_context[i] = malloc(sizeof(*worker_context[i]));
|
||||
worker_context[i]->term = term;
|
||||
worker_context[i]->my_id = 1 + i;
|
||||
thrd_create(&term->render.workers.threads[i], &render_worker_thread, worker_context[i]);
|
||||
struct render_worker_context *ctx = malloc(sizeof(*ctx));
|
||||
*ctx = (struct render_worker_context) {
|
||||
.term = term,
|
||||
.my_id = 1 + i,
|
||||
};
|
||||
thrd_create(&term->render.workers.threads[i], &render_worker_thread, ctx);
|
||||
}
|
||||
|
||||
font_list_t font_names = tll_init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue