forked from cory/tildefriends
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:
14
src/ssb.js.c
14
src/ssb.js.c
@ -1,12 +1,12 @@
|
||||
#include "ssb.js.h"
|
||||
|
||||
#include "database.js.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.h"
|
||||
#include "task.h"
|
||||
#include "util.js.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <sodium/crypto_hash_sha256.h>
|
||||
#include <sodium/crypto_sign.h>
|
||||
#include <string.h>
|
||||
@ -48,7 +48,7 @@ static JSValue _tf_ssb_getMessage(JSContext* context, JSValueConst this_val, int
|
||||
result = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, result, "timestamp", JS_NewFloat64(context, timestamp));
|
||||
JS_SetPropertyStr(context, result, "content", JS_NewString(context, contents));
|
||||
free(contents);
|
||||
tf_free(contents);
|
||||
}
|
||||
JS_FreeCString(context, id);
|
||||
}
|
||||
@ -67,7 +67,7 @@ static JSValue _tf_ssb_blobGet(JSContext* context, JSValueConst this_val, int ar
|
||||
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
|
||||
{
|
||||
result = JS_NewArrayBufferCopy(context, blob, size);
|
||||
free(blob);
|
||||
tf_free(blob);
|
||||
}
|
||||
JS_FreeCString(context, id);
|
||||
}
|
||||
@ -133,7 +133,7 @@ static JSValue _tf_ssb_messageContentGet(JSContext* context, JSValueConst this_v
|
||||
if (tf_ssb_db_message_content_get(ssb, id, &blob, &size))
|
||||
{
|
||||
result = JS_NewArrayBufferCopy(context, blob, size);
|
||||
free(blob);
|
||||
tf_free(blob);
|
||||
}
|
||||
JS_FreeCString(context, id);
|
||||
}
|
||||
@ -155,7 +155,7 @@ static JSValue _tf_ssb_connections(JSContext* context, JSValueConst this_val, in
|
||||
{
|
||||
JS_SetPropertyUint32(context, result, i, JS_NewString(context, *p));
|
||||
}
|
||||
free(connections);
|
||||
tf_free(connections);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -618,7 +618,7 @@ void tf_ssb_run_file(JSContext* context, const char* file_name)
|
||||
fseek(file, 0, SEEK_END);
|
||||
long file_size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
source = malloc(file_size + 1);
|
||||
source = tf_malloc(file_size + 1);
|
||||
fread(source, 1, file_size, file);
|
||||
source[file_size] = '\0';
|
||||
fclose(file);
|
||||
@ -663,7 +663,7 @@ void tf_ssb_run_file(JSContext* context, const char* file_name)
|
||||
}
|
||||
|
||||
JS_FreeValue(context, result);
|
||||
free(source);
|
||||
tf_free(source);
|
||||
}
|
||||
|
||||
static JSValue _tf_ssb_add_event_listener(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
|
Reference in New Issue
Block a user