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:
@ -1,7 +1,8 @@
|
||||
#include "database.js.h"
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <malloc.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
@ -62,7 +63,7 @@ static JSValue _database_create(JSContext* context, JSValueConst this_val, int a
|
||||
JS_ToInt64(context, &value, data[0]);
|
||||
sqlite3* db = (sqlite3*)(intptr_t)value;
|
||||
|
||||
database_t* database = malloc(sizeof(database_t));
|
||||
database_t* database = tf_malloc(sizeof(database_t));
|
||||
*database = (database_t)
|
||||
{
|
||||
.task = JS_GetContextOpaque(context),
|
||||
@ -71,7 +72,7 @@ static JSValue _database_create(JSContext* context, JSValueConst this_val, int a
|
||||
.db = db,
|
||||
};
|
||||
const char* id = JS_ToCString(context, argv[0]);
|
||||
database->id = strdup(id);
|
||||
database->id = tf_strdup(id);
|
||||
JS_FreeCString(context, id);
|
||||
JS_SetOpaque(object, database);
|
||||
|
||||
@ -90,8 +91,8 @@ static void _database_finalizer(JSRuntime *runtime, JSValue value)
|
||||
database_t* database = JS_GetOpaque(value, _database_class_id);
|
||||
if (database)
|
||||
{
|
||||
free((void*)database->id);
|
||||
free(database);
|
||||
tf_free((void*)database->id);
|
||||
tf_free(database);
|
||||
}
|
||||
--_database_count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user