JSStringRef CYCopyJSString(CYUTF8String value) {
if (memchr(value.data, '\0', value.size) != NULL) {
CYPool pool;
- return CYCopyJSString(pool.memdup(value.data, value.size));
+ return CYCopyJSString(CYPoolUTF16String(pool, value));
} else if (value.data[value.size] != '\0') {
CYPool pool;
- return CYCopyJSString(CYPoolUTF16String(pool, value));
+ return CYCopyJSString(pool.strmemdup(value.data, value.size));
} else {
return CYCopyJSString(value.data);
}
if (owner != NULL)
internal->value_ = data;
else {
- size_t size(typical->GetFFI()->size);
- void *copy(internal->pool_->malloc<void>(size));
- memcpy(copy, data, size);
+ ffi_type *ffi(typical->GetFFI());
+ void *copy(internal->pool_->malloc<void>(ffi->size, ffi->alignment));
+ memcpy(copy, data, ffi->size);
internal->value_ = copy;
}
}
type.PoolFFI(pool, context, field, base, rhs);
- // XXX: alignment?
base += field->size;
}
}
}
element->type->PoolFFI(pool, context, field, base, rhs);
- // XXX: alignment?
base += field->size;
}
}
for (size_t index(setups); index != size; ++index) {
sig::Element *element(&signature->elements[index + 1]);
ffi_type *ffi(cif->arg_types[index]);
- // XXX: alignment?
- values[index] = new(pool) uint8_t[ffi->size];
+ values[index] = pool.malloc<uint8_t>(ffi->size, ffi->alignment);
element->type->PoolFFI(&pool, context, ffi, values[index], arguments[index - setups]);
}
if (sig::Function *function = dynamic_cast<sig::Function *>(internal->type_))
return CYMakeFunctor(context, arguments[0], function->signature);
+ CYPool pool;
sig::Type *type(internal->type_);
ffi_type *ffi(internal->GetFFI());
- // XXX: alignment?
- uint8_t value[ffi->size];
- CYPool pool;
+ void *value(pool.malloc<void>(ffi->size, ffi->alignment));
type->PoolFFI(&pool, context, ffi, value, arguments[0]);
return type->FromFFI(context, ffi, value);
} CYCatch(NULL) }
JSObjectRef pointer(CYMakePointer(context, NULL, length, *type, NULL, NULL));
Pointer *value(reinterpret_cast<Pointer *>(JSObjectGetPrivate(pointer)));
- value->value_ = value->pool_->malloc<void>(internal->GetFFI()->size);
- memset(value->value_, 0, internal->GetFFI()->size);
+ ffi_type *ffi(internal->GetFFI());
+ value->value_ = value->pool_->malloc<void>(ffi->size, ffi->alignment);
+ memset(value->value_, 0, ffi->size);
return pointer;
} CYCatch(NULL) }