Skip to content

Commit

Permalink
utils: remove custom JS_FreePropEnum function
Browse files Browse the repository at this point in the history
We now have an equivalent public one in QuickJS.
  • Loading branch information
saghul committed Jan 27, 2025
1 parent ab99b0e commit 463dab8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/mod_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ static JSValue tjs_spawn(JSContext *ctx, JSValue this_val, int argc, JSValue *ar
}
options.env = js_mallocz(ctx, sizeof(*options.env) * (plen + 1));
if (!options.env) {
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
JS_FreeValue(ctx, js_env);
goto fail;
}
for (int i = 0; i < plen; i++) {
JSValue prop = JS_GetProperty(ctx, js_env, ptab[i].atom);
if (JS_IsException(prop)) {
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
JS_FreeValue(ctx, js_env);
goto fail;
}
Expand All @@ -309,15 +309,15 @@ static JSValue tjs_spawn(JSContext *ctx, JSValue this_val, int argc, JSValue *ar
if (!options.env[i]) {
JS_FreeCString(ctx, key);
JS_FreeCString(ctx, value);
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
JS_FreeValue(ctx, js_env);
goto fail;
}
snprintf(options.env[i], len, "%s=%s", key, value);
JS_FreeCString(ctx, key);
JS_FreeCString(ctx, value);
}
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
}
JS_FreeValue(ctx, js_env);

Expand Down
6 changes: 3 additions & 3 deletions src/mod_sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static JSValue tjs__sqlite3_bind_params(JSContext *ctx, sqlite3_stmt *stmt, JSVa
JSAtom patom = ptab[i].atom;
JSValue prop = JS_GetProperty(ctx, params, patom);
if (JS_IsException(prop)) {
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
return JS_EXCEPTION;
}
const char *key = JS_AtomToCString(ctx, patom);
Expand All @@ -494,13 +494,13 @@ static JSValue tjs__sqlite3_bind_params(JSContext *ctx, sqlite3_stmt *stmt, JSVa
}
JS_FreeValue(ctx, prop);
JS_FreeCString(ctx, key);
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
return JS_EXCEPTION;
}
JS_FreeValue(ctx, prop);
JS_FreeCString(ctx, key);
}
JS_FreePropEnum(ctx, ptab, plen);
JS_FreePropertyEnum(ctx, ptab, plen);
} else {
return JS_ThrowTypeError(ctx, "Invalid bind parameters type: expected object or array");
}
Expand Down
10 changes: 0 additions & 10 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,6 @@ void tjs_call_handler(JSContext *ctx, JSValue func, int argc, JSValue *argv) {
JS_FreeValue(ctx, ret);
}

void JS_FreePropEnum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len) {
uint32_t i;
if (tab) {
for (i = 0; i < len; i++) {
JS_FreeAtom(ctx, tab[i].atom);
}
js_free(ctx, tab);
}
}

JSValue TJS_InitPromise(JSContext *ctx, TJSPromise *p) {
JSValue rfuncs[2];
p->p = JS_NewPromiseCapability(ctx, rfuncs);
Expand Down
1 change: 0 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void tjs_addr2obj(JSContext *ctx, JSValue obj, const struct sockaddr *sa, bool s
void tjs_call_handler(JSContext *ctx, JSValue func, int argc, JSValue *argv);
void tjs_dump_error(JSContext *ctx);
void tjs_dump_error1(JSContext *ctx, JSValue exception_val);
void JS_FreePropEnum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len);

typedef struct {
JSValue p;
Expand Down

0 comments on commit 463dab8

Please sign in to comment.