Use a custom allocator for everything.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3892 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-06-04 17:04:51 +00:00
parent cf61e68713
commit 9c90b2bc1d
24 changed files with 404 additions and 343 deletions

View File

@ -1,11 +1,11 @@
#include "taskstub.js.h"
#include "mem.h"
#include "packetstream.h"
#include "serialize.h"
#include "task.h"
#include "util.js.h"
#include <malloc.h>
#include <string.h>
#include <stdio.h>
@ -68,7 +68,7 @@ static void _taskstub_finalizer(JSRuntime *runtime, JSValue value);
static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_task_t* parent = tf_task_get(context);
tf_taskstub_t* stub = malloc(sizeof(tf_taskstub_t));
tf_taskstub_t* stub = tf_malloc(sizeof(tf_taskstub_t));
memset(stub, 0, sizeof(*stub));
stub->_stream = tf_packetstream_create();
@ -216,7 +216,7 @@ tf_task_t* tf_taskstub_get_owner(const tf_taskstub_t* stub)
tf_taskstub_t* tf_taskstub_create_parent(tf_task_t* task, uv_file file)
{
JSValue parentObject = JS_NewObject(tf_task_get_context(task));
tf_taskstub_t* parentStub = malloc(sizeof(tf_taskstub_t));
tf_taskstub_t* parentStub = tf_malloc(sizeof(tf_taskstub_t));
memset(parentStub, 0, sizeof(tf_taskstub_t));
parentStub->_stream = tf_packetstream_create();
parentStub->_on_exit = JS_UNDEFINED;
@ -249,7 +249,7 @@ static void _taskstub_cleanup(tf_taskstub_t* stub)
JS_IsUndefined(stub->_object) &&
stub->_finalized)
{
free(stub);
tf_free(stub);
}
}
@ -321,7 +321,7 @@ static JSValue _taskstub_setImports(JSContext* context, JSValueConst this_val, i
size_t size;
tf_serialize_store(tf_task_get(context), stub, &buffer, &size, argv[0]);
tf_packetstream_send(stub->_stream, kSetImports, (char*)buffer, size);
free(buffer);
tf_free(buffer);
return JS_UNDEFINED;
}
@ -332,7 +332,7 @@ static JSValue _taskstub_setRequires(JSContext* context, JSValueConst this_val,
size_t size;
tf_serialize_store(tf_task_get(context), stub, &buffer, &size, argv[0]);
tf_packetstream_send(stub->_stream, kSetRequires, (char*)buffer, size);
free(buffer);
tf_free(buffer);
return JS_UNDEFINED;
}
@ -343,7 +343,7 @@ static JSValue _taskstub_loadFile(JSContext* context, JSValueConst this_val, int
size_t size;
tf_serialize_store(tf_task_get(context), stub, &buffer, &size, argv[0]);
tf_packetstream_send(stub->_stream, kLoadFile, (char*)buffer, size);
free(buffer);
tf_free(buffer);
return JS_UNDEFINED;
}