Revert "wip"

This reverts commit c3cfa64d26.
This commit is contained in:
Marcel Hollerbach 2021-04-10 10:08:04 +02:00
parent c3cfa64d26
commit 9617cf1b85
1 changed files with 7 additions and 18 deletions

View File

@ -1148,7 +1148,6 @@ typedef struct _Base_Ctx {
Eina_Promise *promise; Eina_Promise *promise;
Eina_Future **futures; Eina_Future **futures;
unsigned int futures_len; unsigned int futures_len;
unsigned char inside_free;
} Base_Ctx; } Base_Ctx;
typedef struct _All_Promise_Ctx { typedef struct _All_Promise_Ctx {
@ -1162,30 +1161,21 @@ typedef struct _Race_Promise_Ctx {
Eina_Bool dispatching; Eina_Bool dispatching;
} Race_Promise_Ctx; } Race_Promise_Ctx;
static short static void
_base_ctx_clean(Base_Ctx *ctx) _base_ctx_clean(Base_Ctx *ctx)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ctx->futures_len; i++)
ctx->inside_free++;
for (i = 0; i < ctx->futures_len && ctx->futures; i++)
if (ctx->futures[i]) _eina_future_cancel(ctx->futures[i], ECANCELED); if (ctx->futures[i]) _eina_future_cancel(ctx->futures[i], ECANCELED);
//prepare against double free free(ctx->futures);
Eina_Future **futures = ctx->futures;
ctx->futures = NULL;
if (futures)
free(futures);
ctx->inside_free--;
return ctx->inside_free;
} }
static void static void
_all_promise_ctx_free(All_Promise_Ctx *ctx) _all_promise_ctx_free(All_Promise_Ctx *ctx)
{ {
int depth = _base_ctx_clean(&ctx->base); _base_ctx_clean(&ctx->base);
eina_value_flush(&ctx->values); eina_value_flush(&ctx->values);
if (depth == 0) free(ctx);
free(ctx);
} }
static void static void
@ -1197,9 +1187,8 @@ _all_promise_cancel(void *data, const Eina_Promise *dead EINA_UNUSED)
static void static void
_race_promise_ctx_free(Race_Promise_Ctx *ctx) _race_promise_ctx_free(Race_Promise_Ctx *ctx)
{ {
int depth = _base_ctx_clean(&ctx->base); _base_ctx_clean(&ctx->base);
if (depth == 0) free(ctx);
free(ctx);
} }
static void static void