diff --git a/moo/lib/bigint.c b/moo/lib/bigint.c index e458b0a..5349d8d 100644 --- a/moo/lib/bigint.c +++ b/moo/lib/bigint.c @@ -70,7 +70,7 @@ #define IS_SIGN_DIFF(x,y) (((x) ^ (y)) < 0) /* digit character array */ -static char* _digitc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +static char _digitc[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* exponent table */ static moo_uint8_t _exp_tab[] = @@ -1166,12 +1166,12 @@ static MOO_INLINE moo_oow_t multiply_unsigned_array_karatsuba (moo_t* moo, const tmplen[0] = ndigits_xh + ndigits_yh; tmplen[1] = ndigits_yl + ndigits_yh + 1; if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0]; - tmp[1] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */ + tmp[1] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */ if (!tmp[1]) goto oops; /* make a temporary for (a0 + a1) and (a0 * b0) */ tmplen[0] = ndigits_xl + ndigits_yl + 1; - tmp[0] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); + tmp[0] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); if (!tmp[0]) goto oops; /* tmp[0] = a0 + a1 */ @@ -1286,12 +1286,12 @@ oops: tmplen[0] = ndigits_yl + ndigits_yh + 1; tmplen[1] = ndigits_xh + ndigits_yh; if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0]; - tmp[1] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); + tmp[1] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); if (!tmp[1]) goto oops; /* make a temporary for (a0 + a1) and (a0 * b0) */ tmplen[0] = ndigits_xl + ndigits_yl; - tmp[0] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); + tmp[0] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); if (!tmp[0]) goto oops; /* tmp[0] = a0 + a1 */ diff --git a/moo/lib/gc.c b/moo/lib/gc.c index b6e1216..7af3b5a 100644 --- a/moo/lib/gc.c +++ b/moo/lib/gc.c @@ -1036,7 +1036,7 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop) total_bytes = MOO_SIZEOF(moo_obj_t) + get_payload_bytes(moo, oop); moo_pushtmp (moo, &oop); - z = moo_allocbytes (moo, total_bytes); + z = (moo_oop_t)moo_allocbytes (moo, total_bytes); moo_poptmp(moo); MOO_MEMCPY (z, oop, total_bytes); @@ -1059,7 +1059,7 @@ int moo_regfinalizable (moo_t* moo, moo_oop_t oop) return -1; } - x = moo_allocmem (moo, MOO_SIZEOF(*x)); + x = (moo_finalizable_t*)moo_allocmem(moo, MOO_SIZEOF(*x)); if (!x) return -1; MOO_OBJ_SET_FLAGS_GCFIN (oop, MOO_GCFIN_FINALIZABLE); diff --git a/moo/lib/logfmtv.h b/moo/lib/logfmtv.h index 13e223b..1321930 100644 --- a/moo/lib/logfmtv.h +++ b/moo/lib/logfmtv.h @@ -92,14 +92,15 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_list ap, outbfmt_t outbfmt) { const fmtchar_t* percent; -#if defined(FMTCHAR_IS_OOCH) const fmtchar_t* checkpoint; -#endif moo_bch_t nbuf[MAXNBUF], bch; const moo_bch_t* nbufp; int n, base, neg, sign; moo_ooi_t tmp, width, precision; moo_ooch_t ch, padc; +#if !defined(FMTCHAR_IS_OOCH) + fmtchar_t fch; +#endif int lm_flag, lm_dflag, flagc, numlen; moo_uintmax_t num = 0; int stop = 0; @@ -137,11 +138,38 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis } PUT_OOCS (checkpoint, fmt - checkpoint - 1); #else - while ((ch = *fmt++) != '%' || stop) + #if defined(MOO_OOCH_IS_UCH) + /* fmtchar is bch. ooch is uch. convert bch to uch */ + checkpoint = fmt; + while ((fch = *fmt++) != '%' || stop) { - if (ch == '\0') goto done; + if (fch == '\0') break; + } + while (checkpoint < fmt - 1) + { + moo_oow_t cvlen, bclen; + bclen = fmt - checkpoint - 1; + cvlen = moo->cmgr->bctouc(checkpoint, bclen, &ch); + if (cvlen == 0 || cvlen > bclen) goto oops; + checkpoint += cvlen; PUT_OOCH (ch, 1); } + if (fch == '\0') goto done; + #else + while ((fch = *fmt++) != '%' || stop) + { + moo_bch_t bcsbuf[MOO_MBLEN_MAX + 1]; + moo_oow_t ucslen, bcslen; + + if (fch == '\0') goto done; + + /* fmtchar is uch. ooch is bch. convert uch to bch */ + ucslen = 1; + bcslen = MOO_COUNTOF(bcsbuf); + if (moo_convutooochars(moo, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops; + PUT_OOCS (bcsbuf, bcslen); + } + #endif #endif percent = fmt - 1; diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 742237d..2773d42 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -322,66 +322,67 @@ struct moo_ioarg_t /*-----------------------------------------------------------------*/ }; +enum moo_iotok_type_t +{ + MOO_IOTOK_EOF, + + MOO_IOTOK_CHARLIT, + MOO_IOTOK_STRLIT, + MOO_IOTOK_SYMLIT, + MOO_IOTOK_NUMLIT, + MOO_IOTOK_RADNUMLIT, + MOO_IOTOK_ERRLIT, /* error(NN) */ + + MOO_IOTOK_ERROR, /* error */ + MOO_IOTOK_NIL, + MOO_IOTOK_SELF, + MOO_IOTOK_SUPER, + MOO_IOTOK_TRUE, + MOO_IOTOK_FALSE, + MOO_IOTOK_THIS_CONTEXT, + MOO_IOTOK_THIS_PROCESS, + MOO_IOTOK_SELFNS, + + MOO_IOTOK_IF, + MOO_IOTOK_ELSE, + MOO_IOTOK_ELSIF, + + MOO_IOTOK_WHILE, + MOO_IOTOK_UNTIL, + MOO_IOTOK_DO, + MOO_IOTOK_BREAK, + MOO_IOTOK_CONTINUE, + + MOO_IOTOK_IDENT, + MOO_IOTOK_IDENT_DOTTED, + MOO_IOTOK_BINSEL, + MOO_IOTOK_KEYWORD, + MOO_IOTOK_ASSIGN, /* := */ + MOO_IOTOK_COLON, /* : */ + MOO_IOTOK_PERCENT, /* % */ + MOO_IOTOK_RETURN, /* ^ */ + MOO_IOTOK_LOCAL_RETURN, /* ^^ */ + MOO_IOTOK_LBRACE, + MOO_IOTOK_RBRACE, + MOO_IOTOK_LBRACK, + MOO_IOTOK_RBRACK, + MOO_IOTOK_LPAREN, + MOO_IOTOK_RPAREN, + MOO_IOTOK_HASHPAREN, /* #( - array literal */ + MOO_IOTOK_HASHBRACK, /* #[ - byte array literal */ + MOO_IOTOK_PERCPAREN, /* %( - array expression */ + MOO_IOTOK_PERCBRACE, /* %{ - dictionary expression */ + MOO_IOTOK_PERIOD, + MOO_IOTOK_COMMA, + MOO_IOTOK_SEMICOLON +}; +typedef enum moo_iotok_type_t moo_iotok_type_t; + struct moo_iotok_t { - enum - { - MOO_IOTOK_EOF, - - MOO_IOTOK_CHARLIT, - MOO_IOTOK_STRLIT, - MOO_IOTOK_SYMLIT, - MOO_IOTOK_NUMLIT, - MOO_IOTOK_RADNUMLIT, - MOO_IOTOK_ERRLIT, /* error(NN) */ - - MOO_IOTOK_ERROR, /* error */ - MOO_IOTOK_NIL, - MOO_IOTOK_SELF, - MOO_IOTOK_SUPER, - MOO_IOTOK_TRUE, - MOO_IOTOK_FALSE, - MOO_IOTOK_THIS_CONTEXT, - MOO_IOTOK_THIS_PROCESS, - MOO_IOTOK_SELFNS, - - MOO_IOTOK_IF, - MOO_IOTOK_ELSE, - MOO_IOTOK_ELSIF, - - MOO_IOTOK_WHILE, - MOO_IOTOK_UNTIL, - MOO_IOTOK_DO, - MOO_IOTOK_BREAK, - MOO_IOTOK_CONTINUE, - - MOO_IOTOK_IDENT, - MOO_IOTOK_IDENT_DOTTED, - MOO_IOTOK_BINSEL, - MOO_IOTOK_KEYWORD, - MOO_IOTOK_ASSIGN, /* := */ - MOO_IOTOK_COLON, /* : */ - MOO_IOTOK_PERCENT, /* % */ - MOO_IOTOK_RETURN, /* ^ */ - MOO_IOTOK_LOCAL_RETURN, /* ^^ */ - MOO_IOTOK_LBRACE, - MOO_IOTOK_RBRACE, - MOO_IOTOK_LBRACK, - MOO_IOTOK_RBRACK, - MOO_IOTOK_LPAREN, - MOO_IOTOK_RPAREN, - MOO_IOTOK_HASHPAREN, /* #( - array literal */ - MOO_IOTOK_HASHBRACK, /* #[ - byte array literal */ - MOO_IOTOK_PERCPAREN, /* %( - array expression */ - MOO_IOTOK_PERCBRACE, /* %{ - dictionary expression */ - MOO_IOTOK_PERIOD, - MOO_IOTOK_COMMA, - MOO_IOTOK_SEMICOLON - } type; - + moo_iotok_type_t type; moo_oocs_t name; moo_oow_t name_capa; - moo_ioloc_t loc; }; typedef struct moo_iotok_t moo_iotok_t; diff --git a/moo/lib/moo-rbt.h b/moo/lib/moo-rbt.h index 6b37c80..9675729 100644 --- a/moo/lib/moo-rbt.h +++ b/moo/lib/moo-rbt.h @@ -167,6 +167,13 @@ typedef moo_rbt_pair_t* (*moo_rbt_cbserter_t) ( void* ctx /**< callback context */ ); +enum moo_rbt_pair_color_t +{ + MOO_RBT_RED, + MOO_RBT_BLACK +}; +typedef enum moo_rbt_pair_color_t moo_rbt_pair_color_t; + /** * The moo_rbt_pair_t type defines red-black tree pair. A pair is composed * of a key and a value. It maintains pointers to the beginning of a key and @@ -188,11 +195,7 @@ struct moo_rbt_pair_t } val; /* management information below */ - enum - { - MOO_RBT_RED, - MOO_RBT_BLACK - } color; + moo_rbt_pair_color_t color; moo_rbt_pair_t* parent; moo_rbt_pair_t* child[2]; /* left and right */ }; diff --git a/moo/lib/moo.c b/moo/lib/moo.c index 5f4c84f..02af39e 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -33,7 +33,7 @@ moo_t* moo_open (moo_mmgr_t* mmgr, moo_oow_t xtnsize, moo_oow_t heapsize, const /* if this assertion fails, correct the type definition in moo.h */ MOO_ASSERT (moo, MOO_SIZEOF(moo_oow_t) == MOO_SIZEOF(moo_oop_t)); - moo = MOO_MMGR_ALLOC (mmgr, MOO_SIZEOF(*moo) + xtnsize); + moo = (moo_t*)MOO_MMGR_ALLOC(mmgr, MOO_SIZEOF(*moo) + xtnsize); if (moo) { if (moo_init(moo, mmgr, heapsize, vmprim) <= -1) @@ -369,7 +369,7 @@ moo_cb_t* moo_regcb (moo_t* moo, moo_cb_t* tmpl) { moo_cb_t* actual; - actual = moo_allocmem (moo, MOO_SIZEOF(*actual)); + actual = (moo_cb_t*)moo_allocmem(moo, MOO_SIZEOF(*actual)); if (!actual) return MOO_NULL; *actual = *tmpl; diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 702a139..e7d2c0d 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1103,7 +1103,7 @@ typedef void (*moo_mod_gc_t) ( struct moo_mod_t { /* input */ - const moo_ooch_t name[MOO_MOD_NAME_LEN_MAX + 1]; + /*const*/ moo_ooch_t name[MOO_MOD_NAME_LEN_MAX + 1]; /*const*/ int hints; /* bitwised-ORed of moo_mod_hint_t enumerators */ /* user-defined data */ @@ -1342,7 +1342,7 @@ struct moo_t { struct { - moo_uch_t* ptr; + moo_ooch_t* ptr; moo_oow_t capa; moo_oow_t len; } xbuf; diff --git a/moo/lib/obj.c b/moo/lib/obj.c index ff805b2..894ee97 100644 --- a/moo/lib/obj.c +++ b/moo/lib/obj.c @@ -34,7 +34,7 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size) if ((moo->option.trait & MOO_DEBUG_GC) && !(moo->option.trait & MOO_NOGC)) moo_gc (moo); #endif - ptr = moo_allocheapmem (moo, moo->curheap, size); + ptr = (moo_uint8_t*)moo_allocheapmem(moo, moo->curheap, size); if (!ptr && moo->errnum == MOO_EOOMEM && !(moo->option.trait & MOO_NOGC)) { moo_gc (moo); @@ -44,7 +44,7 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size) (moo_oow_t)(moo->curheap->limit - moo->curheap->base), (moo_oow_t)(moo->curheap->limit - moo->curheap->ptr) ); - ptr = moo_allocheapmem (moo, moo->curheap, size); + ptr = (moo_uint8_t*)moo_allocheapmem(moo, moo->curheap, size); /* TODO: grow heap if ptr is still null. */ } @@ -66,7 +66,7 @@ moo_oop_t moo_allocoopobj (moo_t* moo, moo_oow_t size) * MOO_SIZEOF(moo_oop_t) will guarantee the starting address * of the allocated space to be an even number. * see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */ - hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); + hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); if (!hdr) return MOO_NULL; hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 0); @@ -88,7 +88,7 @@ moo_oop_t moo_allocoopobjwithtrailer (moo_t* moo, moo_oow_t size, const moo_oob_ nbytes = (size + 1) * MOO_SIZEOF(moo_oop_t) + blen; nbytes_aligned = MOO_ALIGN(nbytes, MOO_SIZEOF(moo_oop_t)); - hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); + hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); if (!hdr) return MOO_NULL; hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 1); @@ -128,7 +128,7 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo if (MOO_UNLIKELY(ngc)) { - hdr = moo_callocmem (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); + hdr = (moo_oop_t)moo_callocmem(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); if (!hdr) return MOO_NULL; } else @@ -137,7 +137,7 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo * MOO_SIZEOF(moo_oop_t) will guarantee the starting address * of the allocated space to be an even number. * see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */ - hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); + hdr = (moo_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); if (!hdr) return MOO_NULL; } @@ -163,22 +163,22 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo MOO_INLINE moo_oop_t moo_alloccharobj (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len) { - return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_CHAR, MOO_SIZEOF(moo_ooch_t), 1, 0); + return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_CHAR, MOO_SIZEOF(moo_ooch_t), 1, 0); } MOO_INLINE moo_oop_t moo_allocbyteobj (moo_t* moo, const moo_oob_t* ptr, moo_oow_t len) { - return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_BYTE, MOO_SIZEOF(moo_oob_t), 0, 0); + return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_BYTE, MOO_SIZEOF(moo_oob_t), 0, 0); } MOO_INLINE moo_oop_t moo_allochalfwordobj (moo_t* moo, const moo_oohw_t* ptr, moo_oow_t len) { - return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_HALFWORD, MOO_SIZEOF(moo_oohw_t), 0, 0); + return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_HALFWORD, MOO_SIZEOF(moo_oohw_t), 0, 0); } MOO_INLINE moo_oop_t moo_allocwordobj (moo_t* moo, const moo_oow_t* ptr, moo_oow_t len) { - return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0, 0); + return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0, 0); } static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t num_flexi_fields, moo_obj_type_t* type, moo_oow_t* outlen) @@ -251,7 +251,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr, case MOO_OBJ_TYPE_OOP: /* both the fixed part(named instance variables) and * the variable part(indexed instance variables) are allowed. */ - oop = moo_allocoopobj (moo, alloclen); + oop = moo_allocoopobj(moo, alloclen); if (oop) { /* initialize named instance variables with default values */ @@ -291,19 +291,19 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr, break; case MOO_OBJ_TYPE_CHAR: - oop = moo_alloccharobj (moo, vptr, alloclen); + oop = moo_alloccharobj(moo, vptr, alloclen); break; case MOO_OBJ_TYPE_BYTE: - oop = moo_allocbyteobj (moo, vptr, alloclen); + oop = moo_allocbyteobj(moo, vptr, alloclen); break; case MOO_OBJ_TYPE_HALFWORD: - oop = moo_allochalfwordobj (moo, vptr, alloclen); + oop = moo_allochalfwordobj(moo, vptr, alloclen); break; case MOO_OBJ_TYPE_WORD: - oop = moo_allocwordobj (moo, vptr, alloclen); + oop = moo_allocwordobj(moo, vptr, alloclen); break; default: diff --git a/moo/lib/utl.c b/moo/lib/utl.c index 0eb3381..f900827 100644 --- a/moo/lib/utl.c +++ b/moo/lib/utl.c @@ -369,7 +369,7 @@ int moo_concatoocstrtosbuf (moo_t* moo, const moo_ooch_t* str, int id) newcapa = MOO_ALIGN(p->len + len, 512); /* TODO: adjust this capacity */ /* +1 to handle line ending injection more easily */ - tmp = moo_reallocmem (moo, p->ptr, (newcapa + 1) * MOO_SIZEOF(*tmp)); + tmp = (moo_ooch_t*)moo_reallocmem(moo, p->ptr, (newcapa + 1) * MOO_SIZEOF(*tmp)); if (!tmp) return -1; p->ptr = tmp; @@ -731,7 +731,7 @@ int moo_convbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_ /* length bound */ int n; - n = bcsn_to_ucsn_with_cmgr (bcs, bcslen, ucs, ucslen, moo->cmgr, 0); + n = bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); if (n <= -1) { @@ -747,7 +747,7 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_ /* length bound */ int n; - n = ucsn_to_bcsn_with_cmgr (ucs, ucslen, bcs, bcslen, moo->cmgr); + n = ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); if (n <= -1) { @@ -762,7 +762,7 @@ int moo_convbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_u /* null-terminated. */ int n; - n = bcs_to_ucs_with_cmgr (bcs, bcslen, ucs, ucslen, moo->cmgr, 0); + n = bcs_to_ucs_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); if (n <= -1) { @@ -777,7 +777,7 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b /* null-terminated */ int n; - n = ucs_to_bcs_with_cmgr (ucs, ucslen, bcs, bcslen, moo->cmgr); + n = ucs_to_bcs_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); if (n <= -1) { @@ -795,13 +795,13 @@ MOO_INLINE moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headro moo_uch_t* ptr; inlen = bcslen; - if (moo_convbtouchars (moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) + if (moo_convbtouchars(moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return MOO_NULL; } - ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_uch_t))); + ptr = (moo_uch_t*)moo_allocmem(moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_uch_t))); if (!ptr) return MOO_NULL; inlen = bcslen; @@ -828,13 +828,13 @@ MOO_INLINE moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headro moo_bch_t* ptr; inlen = ucslen; - if (moo_convutobchars (moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) + if (moo_convutobchars(moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return MOO_NULL; } - ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_bch_t))); + ptr = (moo_bch_t*)moo_allocmem(moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_bch_t))); if (!ptr) return MOO_NULL; inlen = ucslen; @@ -859,14 +859,14 @@ MOO_INLINE moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroo moo_oow_t inlen, outlen; moo_uch_t* ptr; - if (moo_convbtoucstr (moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) + if (moo_convbtoucstr(moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return MOO_NULL; } outlen++; - ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_uch_t))); + ptr = (moo_uch_t*)moo_allocmem(moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_uch_t))); if (!ptr) return MOO_NULL; moo_convbtoucstr (moo, bcs, &inlen, ptr, &outlen); @@ -884,14 +884,14 @@ MOO_INLINE moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroo moo_oow_t inlen, outlen; moo_bch_t* ptr; - if (moo_convutobcstr (moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) + if (moo_convutobcstr(moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return MOO_NULL; } outlen++; - ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_bch_t))); + ptr = (moo_bch_t*)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); @@ -911,7 +911,7 @@ moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen) { moo_uch_t* ptr; - ptr = moo_allocmem (moo, (ucslen + 1) * MOO_SIZEOF(moo_uch_t)); + ptr = (moo_uch_t*)moo_allocmem(moo, (ucslen + 1) * MOO_SIZEOF(moo_uch_t)); if (!ptr) return MOO_NULL; moo_copyuchars (ptr, ucs, ucslen); @@ -923,7 +923,7 @@ moo_bch_t* moo_dupbchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen) { moo_bch_t* ptr; - ptr = moo_allocmem (moo, (bcslen + 1) * MOO_SIZEOF(moo_bch_t)); + ptr = (moo_bch_t*)moo_allocmem(moo, (bcslen + 1) * MOO_SIZEOF(moo_bch_t)); if (!ptr) return MOO_NULL; moo_copybchars (ptr, bcs, bcslen);