added some argument checks into ffi
added more string manipulation functiions
This commit is contained in:
@ -420,7 +420,7 @@ static MOO_INLINE moo_oop_t make_bloated_bigint_with_ooi (moo_t* moo, moo_ooi_t
|
||||
if (i >= 0)
|
||||
{
|
||||
w = i;
|
||||
z =moo_instantiate (moo, moo->_large_positive_integer, MOO_NULL, 1 + extra);
|
||||
z = moo_instantiate (moo, moo->_large_positive_integer, MOO_NULL, 1 + extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -284,7 +284,7 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
* unit: the size of a payload item in bytes.
|
||||
* extra: 0 or 1. 1 indicates that the payload contains 1 more
|
||||
* item than the value of the size field. used for a
|
||||
* terminating null in a variable-char object. internel
|
||||
* terminating null in a variable-character object. internel
|
||||
* use only.
|
||||
* kernel: 0 or 1. indicates that the object is a kernel object.
|
||||
* VM disallows layout changes of a kernel object.
|
||||
@ -1471,6 +1471,9 @@ int moo_convutobcstr (
|
||||
# define moo_dupbtooocharswithheadroom(moo,hrb,bcs,bcslen,oocslen) moo_dupbtoucharswithheadroom(moo,hrb,bcs,bcslen,oocslen)
|
||||
# define moo_dupootobchars(moo,oocs,oocslen,bcslen) moo_duputobchars(moo,oocs,oocslen,bcslen)
|
||||
# define moo_dupbtooochars(moo,bcs,bcslen,oocslen) moo_dupbtouchars(moo,bcs,bcslen,oocslen)
|
||||
|
||||
# define moo_dupootobcstrwithheadroom(moo,hrb,oocs,bcslen) moo_duputobcstrwithheadroom(moo,hrb,oocs,bcslen)
|
||||
# define moo_dupbtooocstrwithheadroom(moo,hrb,bcs,oocslen) moo_dupbtoucstrwithheadroom(moo,hrb,bcs,oocslen)
|
||||
# define moo_dupootobcstr(moo,oocs,bcslen) moo_duputobcstr(moo,oocs,bcslen)
|
||||
# define moo_dupbtooocstr(moo,bcs,oocslen) moo_dupbtoucstr(moo,bcs,oocslen)
|
||||
#else
|
||||
@ -1478,6 +1481,9 @@ int moo_convutobcstr (
|
||||
# define moo_duputooocharswithheadroom(moo,hrb,ucs,ucslen,oocslen) moo_duputobcharswithheadroom(moo,hrb,ucs,ucslen,oocslen)
|
||||
# define moo_dupootouchars(moo,oocs,oocslen,ucslen) moo_dupbtouchars(moo,oocs,oocslen,ucslen)
|
||||
# define moo_duputooochars(moo,ucs,ucslen,oocslen) moo_duputobchars(moo,ucs,ucslen,oocslen)
|
||||
|
||||
# define moo_dupootoucstrwithheadroom(moo,hrb,oocs,ucslen) moo_dupbtoucstrwithheadroom(moo,hrb,oocs,ucslen)
|
||||
# define moo_duputooocstrwithheadroom(moo,hrb,ucs,oocslen) moo_duputobcstrwithheadroom(moo,hrb,ucs,oocslen)
|
||||
# define moo_dupootoucstr(moo,oocs,ucslen) moo_dupbtoucstr(moo,oocs,ucslen)
|
||||
# define moo_duputooocstr(moo,ucs,oocslen) moo_duputobcstr(moo,ucs,oocslen)
|
||||
#endif
|
||||
@ -1513,6 +1519,21 @@ MOO_EXPORT moo_bch_t* moo_duputobchars (
|
||||
moo_oow_t* bcslen
|
||||
);
|
||||
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtoucstrwithheadroom (
|
||||
moo_t* moo,
|
||||
moo_oow_t headroom_bytes,
|
||||
const moo_bch_t* bcs,
|
||||
moo_oow_t* ucslen
|
||||
);
|
||||
|
||||
MOO_EXPORT moo_bch_t* moo_duputobcstrwithheadroom (
|
||||
moo_t* moo,
|
||||
moo_oow_t headroom_bytes,
|
||||
const moo_uch_t* ucs,
|
||||
moo_oow_t* bcslen
|
||||
);
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtoucstr (
|
||||
moo_t* moo,
|
||||
const moo_bch_t* bcs,
|
||||
|
@ -732,7 +732,10 @@ moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen,
|
||||
return moo_duputobcharswithheadroom (moo, 0, ucs, ucslen, bcslen);
|
||||
}
|
||||
|
||||
moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
MOO_INLINE moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_uch_t* ptr;
|
||||
@ -744,7 +747,7 @@ moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
}
|
||||
|
||||
outlen++;
|
||||
ptr = moo_allocmem (moo, outlen * MOO_SIZEOF(moo_uch_t));
|
||||
ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_uch_t)));
|
||||
if (!ptr) return MOO_NULL;
|
||||
|
||||
moo_convbtoucstr (moo, bcs, &inlen, ptr, &outlen);
|
||||
@ -752,7 +755,12 @@ moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
{
|
||||
return moo_dupbtoucstrwithheadroom (moo, 0, bcs, ucslen);
|
||||
}
|
||||
|
||||
MOO_INLINE moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_bch_t* ptr;
|
||||
@ -764,14 +772,20 @@ moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
}
|
||||
|
||||
outlen++;
|
||||
ptr = moo_allocmem (moo, outlen * MOO_SIZEOF(moo_bch_t));
|
||||
ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_bch_t)));
|
||||
if (!ptr) return MOO_NULL;
|
||||
|
||||
ptr = (moo_bch_t*)((moo_oob_t*)ptr + headroom_bytes);
|
||||
|
||||
moo_convutobcstr (moo, ucs, &inlen, ptr, &outlen);
|
||||
if (bcslen) *bcslen = outlen;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
{
|
||||
return moo_duputobcstrwithheadroom (moo, 0, ucs, bcslen);
|
||||
}
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen)
|
||||
|
Reference in New Issue
Block a user