Create a util.js.{h,c} from some common things.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3681 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-11-03 22:15:46 +00:00
parent 03a2367532
commit fde7fb4270
9 changed files with 129 additions and 155 deletions

View File

@ -2,6 +2,7 @@
#include "task.h"
#include "tls.h"
#include "tlscontext.js.h"
#include "util.js.h"
#include <assert.h>
#include <string.h>
@ -773,7 +774,7 @@ int _socket_writeBytes(socket_t* socket, promiseid_t promise, int (*callback)(so
result = callback(socket, promise, stringValue, length);
JS_FreeCString(context, stringValue);
}
else if ((array = tf_try_get_array_buffer(context, &length, value)) != 0)
else if ((array = tf_util_try_get_array_buffer(context, &length, value)) != 0)
{
result = callback(socket, promise, (const char*)array, length);
}
@ -781,9 +782,9 @@ int _socket_writeBytes(socket_t* socket, promiseid_t promise, int (*callback)(so
{
size_t offset;
size_t element_size;
JSValue buffer = tf_try_get_typed_array_buffer(context, value, &offset, &length, &element_size);
JSValue buffer = tf_util_try_get_typed_array_buffer(context, value, &offset, &length, &element_size);
size_t size;
if ((array = tf_try_get_array_buffer(context, &size, buffer)) != 0)
if ((array = tf_util_try_get_array_buffer(context, &size, buffer)) != 0)
{
result = callback(socket, promise, (const char*)array, length);
}