Permalink
Browse files

Make all(?) void casts explicit for C++

  • Loading branch information...
1 parent ee89977 commit 5a4beeed2d0c229a3a558650f03c8390da2d556c @silverhammermba silverhammermba committed Jul 29, 2012
Showing with 114 additions and 113 deletions.
  1. +6 −6 src/array.c
  2. +2 −2 src/cdump.c
  3. +13 −13 src/codegen.c
  4. +7 −7 src/dump.c
  5. +1 −1 src/gc.c
  6. +1 −1 src/kernel.c
  7. +11 −11 src/load.c
  8. +1 −0 src/math.c
  9. +2 −2 src/pool.c
  10. +2 −2 src/proc.c
  11. +1 −1 src/range.c
  12. +6 −6 src/st.c
  13. +3 −3 src/state.c
  14. +15 −15 src/string.c
  15. +2 −2 src/struct.c
  16. +1 −1 src/symbol.c
  17. +32 −32 src/time.c
  18. +8 −8 src/vm.c
View
@@ -46,7 +46,7 @@ ary_new_capa(mrb_state *mrb, int capa)
}
a = (struct RArray*)mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
- a->ptr = mrb_calloc(mrb, blen, 1);
+ a->ptr = (mrb_value *)mrb_calloc(mrb, blen, 1);
a->aux.capa = capa;
a->len = 0;
@@ -116,7 +116,7 @@ ary_modify(mrb_state *mrb, struct RArray *a)
p = a->ptr;
len = a->len * sizeof(mrb_value);
- ptr = mrb_malloc(mrb, len);
+ ptr = (mrb_value *)mrb_malloc(mrb, len);
if (p) {
memcpy(ptr, p, len);
}
@@ -132,11 +132,11 @@ static void
ary_make_shared(mrb_state *mrb, struct RArray *a)
{
if (!(a->flags & MRB_ARY_SHARED)) {
- struct mrb_shared_array *shared = mrb_malloc(mrb, sizeof(struct mrb_shared_array));
+ struct mrb_shared_array *shared = (struct mrb_shared_array *)mrb_malloc(mrb, sizeof(struct mrb_shared_array));
shared->refcnt = 1;
if (a->aux.capa > a->len) {
- a->ptr = shared->ptr = mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*a->len+1);
+ a->ptr = shared->ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*a->len+1);
}
else {
shared->ptr = a->ptr;
@@ -173,7 +173,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, int len)
if (capa > a->aux.capa) {
a->aux.capa = capa;
- a->ptr = mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
+ a->ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
}
}
@@ -195,7 +195,7 @@ ary_shrink_capa(mrb_state *mrb, struct RArray *a)
if (capa > a->len && capa < a->aux.capa) {
a->aux.capa = capa;
- a->ptr = mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
+ a->ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
}
}
View
@@ -107,7 +107,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
return -1;
buf_len = MRB_CDUMP_LINE_LEN;
- if ((buf = mrb_malloc(mrb, buf_len)) == 0 ) {
+ if ((buf = (char *)mrb_malloc(mrb, buf_len)) == 0 ) {
return MRB_CDUMP_GENERAL_FAILURE;
}
@@ -144,7 +144,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
str_len = str_format_len(irep->pool[n]) + 1;
if ( str_len > buf_len ) {
buf_len = str_len;
- if ((buf = mrb_realloc(mrb, buf, buf_len)) == 0 ) {
+ if ((buf = (char *)mrb_realloc(mrb, buf, buf_len)) == 0 ) {
return MRB_CDUMP_GENERAL_FAILURE;
}
}
View
@@ -136,7 +136,7 @@ genop(codegen_scope *s, mrb_code i)
{
if (s->pc == s->icapa) {
s->icapa *= 2;
- s->iseq = codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->icapa);
+ s->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->icapa);
}
s->iseq[s->pc] = i;
s->pc++;
@@ -323,7 +323,7 @@ new_lit(codegen_scope *s, mrb_value val)
}
if (s->plen == s->pcapa) {
s->pcapa *= 2;
- s->pool = codegen_realloc(s, s->pool, sizeof(mrb_value)*s->pcapa);
+ s->pool = (mrb_value *)codegen_realloc(s, s->pool, sizeof(mrb_value)*s->pcapa);
}
s->pool[s->plen] = val;
return s->plen++;
@@ -357,7 +357,7 @@ new_sym(codegen_scope *s, mrb_sym sym)
if (s->syms[i] == sym) return i;
}
if (s->slen > 125 && s->slen < 256) {
- s->syms = codegen_realloc(s, s->syms, sizeof(mrb_sym)*65536);
+ s->syms = (mrb_sym *)codegen_realloc(s, s->syms, sizeof(mrb_sym)*65536);
memset(s->syms+s->slen, 0, sizeof(mrb_sym)*(256-s->slen));
s->slen = 256;
}
@@ -556,7 +556,7 @@ attrsym(codegen_scope *s, mrb_sym a)
char *name2;
name = mrb_sym2name_len(s->mrb, a, &len);
- name2 = codegen_palloc(s, len+1);
+ name2 = (char *)codegen_palloc(s, len+1);
memcpy(name2, name, len);
name2[len] = '=';
name2[len+1] = '\0';
@@ -1927,7 +1927,7 @@ static codegen_scope*
scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
{
mrb_pool *pool = mrb_pool_open(mrb);
- codegen_scope *p = mrb_pool_alloc(pool, sizeof(codegen_scope));
+ codegen_scope *p = (codegen_scope *)mrb_pool_alloc(pool, sizeof(codegen_scope));
if (!p) return 0;
memset(p, 0, sizeof(codegen_scope));
@@ -1940,12 +1940,12 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
p->mrb = prev->mrb;
p->icapa = 1024;
- p->iseq = mrb_malloc(mrb, sizeof(mrb_code)*p->icapa);
+ p->iseq = (mrb_code *)mrb_malloc(mrb, sizeof(mrb_code)*p->icapa);
p->pcapa = 32;
- p->pool = mrb_malloc(mrb, sizeof(mrb_value)*p->pcapa);
+ p->pool = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*p->pcapa);
- p->syms = mrb_malloc(mrb, sizeof(mrb_sym)*256);
+ p->syms = (mrb_sym *)mrb_malloc(mrb, sizeof(mrb_sym)*256);
p->lv = lv;
p->sp += node_len(lv)+2;
@@ -1964,20 +1964,20 @@ scope_finish(codegen_scope *s, int idx)
mrb_irep *irep;
mrb_add_irep(mrb, idx);
- irep = mrb->irep[idx] = mrb_malloc(mrb, sizeof(mrb_irep));
+ irep = mrb->irep[idx] = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
irep->idx = idx;
irep->flags = 0;
if (s->iseq) {
- irep->iseq = codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->pc);
+ irep->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->pc);
irep->ilen = s->pc;
}
if (s->pool) {
- irep->pool = codegen_realloc(s, s->pool, sizeof(mrb_value)*s->plen);
+ irep->pool = (mrb_value *)codegen_realloc(s, s->pool, sizeof(mrb_value)*s->plen);
irep->plen = s->plen;
}
if (s->syms) {
- irep->syms = codegen_realloc(s, s->syms, sizeof(mrb_sym)*s->slen);
+ irep->syms = (mrb_sym *)codegen_realloc(s, s->syms, sizeof(mrb_sym)*s->slen);
irep->slen = s->slen;
}
@@ -1991,7 +1991,7 @@ scope_finish(codegen_scope *s, int idx)
static struct loopinfo*
loop_push(codegen_scope *s, enum looptype t)
{
- struct loopinfo *p = codegen_palloc(s, sizeof(struct loopinfo));
+ struct loopinfo *p = (struct loopinfo *)codegen_palloc(s, sizeof(struct loopinfo));
p->type = t;
p->pc1 = p->pc2 = p->pc3 = 0;
View
@@ -335,7 +335,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
int len;
buf_size = MRB_DUMP_DEFAULT_STR_LEN;
- if ((char_buf = mrb_malloc(mrb, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_malloc(mrb, buf_size)) == 0)
goto error_exit;
buf += uint32_dump((uint32_t)irep->plen, buf, type); /* number of pool */
@@ -360,7 +360,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
if ( nlen > buf_size - 1) {
buf_size = nlen + 1;
- if ((char_buf = mrb_realloc(mrb, char_buf, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_realloc(mrb, char_buf, buf_size)) == 0)
goto error_exit;
memset(char_buf, 0, buf_size);
}
@@ -409,7 +409,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
uint16_t buf_size =0;
buf_size = MRB_DUMP_DEFAULT_STR_LEN;
- if ((char_buf = mrb_malloc(mrb, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_malloc(mrb, buf_size)) == 0)
goto error_exit;
buf += uint32_dump((uint32_t)irep->slen, buf, type); /* number of symbol */
@@ -425,7 +425,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
nlen = str_dump_len((char*)name, len, type);
if ( nlen > buf_size - 1) {
buf_size = nlen + 1;
- if ((char_buf = mrb_realloc(mrb, char_buf, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_realloc(mrb, char_buf, buf_size)) == 0)
goto error_exit;
}
memset(char_buf, 0, buf_size);
@@ -461,7 +461,7 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section)
default: return MRB_DUMP_GENERAL_FAILURE;
}
- if ((buf = mrb_calloc(mrb, 1, buf_size)) == 0)
+ if ((buf = (char *)mrb_calloc(mrb, 1, buf_size)) == 0)
return MRB_DUMP_GENERAL_FAILURE;
buf_top = buf;
@@ -598,7 +598,7 @@ dump_irep_record(mrb_state *mrb, int irep_no, FILE* fp, uint32_t *rlen)
if (irep_record_size == 0)
return MRB_DUMP_GENERAL_FAILURE;
- if ((buf = mrb_calloc(mrb, 1, irep_record_size)) == 0)
+ if ((buf = (char *)mrb_calloc(mrb, 1, irep_record_size)) == 0)
return MRB_DUMP_GENERAL_FAILURE;
if ((rc = write_irep_record(mrb, irep_no, buf, rlen, DUMP_TYPE_HEX)) != MRB_DUMP_OK) {
@@ -690,7 +690,7 @@ mrb_bdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
buf_size += get_irep_record_size(mrb, irep_no, DUMP_TYPE_BIN);
buf_size += MRB_DUMP_SIZE_OF_LONG; /* end of file */
- if ((buf = mrb_malloc(mrb, buf_size)) == 0)
+ if ((buf = (char *)mrb_malloc(mrb, buf_size)) == 0)
return MRB_DUMP_GENERAL_FAILURE;
rc = mrb_write_irep(mrb, n, buf);
View
@@ -248,7 +248,7 @@ unlink_free_heap_page(mrb_state *mrb, struct heap_page *page)
static void
add_heap(mrb_state *mrb)
{
- struct heap_page *page = mrb_calloc(mrb, 1, sizeof(struct heap_page));
+ struct heap_page *page = (struct heap_page *)mrb_calloc(mrb, 1, sizeof(struct heap_page));
RVALUE *p, *e;
struct RBasic *prev = NULL;
View
@@ -853,7 +853,7 @@ mrb_obj_methods_m(mrb_state *mrb, mrb_value self)
int argc;
mrb_get_args(mrb, "*", &argv, &argc);
- return mrb_obj_methods(mrb, argc, argv, self, 0); /* everything but private */
+ return mrb_obj_methods(mrb, argc, argv, self, (mrb_method_flag_t)0); /* everything but private */
}
/* 15.3.1.3.32 */
View
@@ -143,7 +143,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
uint16_t buf_size =0;
buf_size = MRB_DUMP_DEFAULT_STR_LEN;
- if ((char_buf = mrb_malloc(mrb, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_malloc(mrb, buf_size)) == 0)
goto error_exit;
pStart = dst;
@@ -192,7 +192,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
if ( pdl > buf_size - 1) {
buf_size = pdl + 1;
- if ((char_buf = mrb_realloc(mrb, char_buf, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_realloc(mrb, char_buf, buf_size)) == 0)
goto error_exit;
}
memset(char_buf, '\0', buf_size);
@@ -219,7 +219,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
if ( snl > buf_size - 1) {
buf_size = snl + 1;
- if ((char_buf = mrb_realloc(mrb, char_buf, buf_size)) == 0)
+ if ((char_buf = (char *)mrb_realloc(mrb, char_buf, buf_size)) == 0)
goto error_exit;
}
memset(char_buf, '\0', buf_size);
@@ -262,7 +262,7 @@ mrb_load_irep(mrb_state *mrb, FILE* fp)
return ret;
len = sizeof(rite_binary_header) + bin_to_uint32(bin_header.rbds);
- if ((rite_dst = mrb_malloc(mrb, len)) == NULL)
+ if ((rite_dst = (unsigned char *)mrb_malloc(mrb, len)) == NULL)
return MRB_DUMP_GENERAL_FAILURE;
dst = rite_dst;
@@ -331,7 +331,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
int ai = mrb_gc_arena_save(mrb);
recordStart = src;
- buf = mrb_malloc(mrb, bufsize);
+ buf = (char *)mrb_malloc(mrb, bufsize);
if (buf == NULL) {
ret = MRB_DUMP_INVALID_IREP;
goto error_exit;
@@ -359,7 +359,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep->ilen = bin_to_uint32(src); //iseq length
src += MRB_DUMP_SIZE_OF_LONG;
if (irep->ilen > 0) {
- if ((irep->iseq = mrb_malloc(mrb, sizeof(mrb_code) * irep->ilen)) == NULL) {
+ if ((irep->iseq = (mrb_code *)mrb_malloc(mrb, sizeof(mrb_code) * irep->ilen)) == NULL) {
ret = MRB_DUMP_GENERAL_FAILURE;
goto error_exit;
}
@@ -380,7 +380,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep->plen = bin_to_uint32(src); //pool length
src += MRB_DUMP_SIZE_OF_LONG;
if (irep->plen > 0) {
- irep->pool = mrb_malloc(mrb, sizeof(mrb_value) * irep->plen);
+ irep->pool = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value) * irep->plen);
if (irep->pool == NULL) {
ret = MRB_DUMP_INVALID_IREP;
goto error_exit;
@@ -394,7 +394,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
if (pdl > bufsize - 1) {
mrb_free(mrb, buf);
bufsize = pdl + 1;
- if ((buf = mrb_malloc(mrb, bufsize)) == NULL) {
+ if ((buf = (char *)mrb_malloc(mrb, bufsize)) == NULL) {
ret = MRB_DUMP_GENERAL_FAILURE;
goto error_exit;
}
@@ -443,7 +443,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep->slen = bin_to_uint32(src); //syms length
src += MRB_DUMP_SIZE_OF_LONG;
if (irep->slen > 0) {
- if ((irep->syms = mrb_malloc(mrb, sizeof(mrb_sym) * irep->slen)) == NULL) {
+ if ((irep->syms = (mrb_sym *)mrb_malloc(mrb, sizeof(mrb_sym) * irep->slen)) == NULL) {
ret = MRB_DUMP_INVALID_IREP;
goto error_exit;
}
@@ -461,7 +461,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
if (snl > bufsize - 1) {
mrb_free(mrb, buf);
bufsize = snl + 1;
- if ((buf = mrb_malloc(mrb, bufsize)) == NULL) {
+ if ((buf = (char *)mrb_malloc(mrb, bufsize)) == NULL) {
ret = MRB_DUMP_GENERAL_FAILURE;
goto error_exit;
}
@@ -509,7 +509,7 @@ mrb_read_irep(mrb_state *mrb, const char *bin)
mrb_add_irep(mrb, sirep + nirep);
for (n=0,i=sirep; n<nirep; n++,i++) {
- if ((mrb->irep[i] = mrb_malloc(mrb, sizeof(mrb_irep))) == NULL) {
+ if ((mrb->irep[i] = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep))) == NULL) {
ret = MRB_DUMP_GENERAL_FAILURE;
goto error_exit;
}
View
@@ -5,6 +5,7 @@
*/
#include "mruby.h"
+#include "mruby/array.h"
#ifdef ENABLE_MATH
#include <math.h>
View
@@ -49,7 +49,7 @@ struct mrb_pool {
mrb_pool*
mrb_pool_open(mrb_state *mrb)
{
- mrb_pool *pool = mrb_malloc(mrb, sizeof(mrb_pool));
+ mrb_pool *pool = (mrb_pool *)mrb_malloc(mrb, sizeof(mrb_pool));
if (pool) {
pool->mrb = mrb;
@@ -81,7 +81,7 @@ page_alloc(mrb_pool *pool, size_t len)
if (len < POOL_PAGE_SIZE)
len = POOL_PAGE_SIZE;
- page = mrb_malloc(pool->mrb, sizeof(struct mrb_pool_page)+len-1);
+ page = (struct mrb_pool_page *)mrb_malloc(pool->mrb, sizeof(struct mrb_pool_page)+len-1);
if (page) {
page->offset = 0;
page->len = len;
View
@@ -144,8 +144,8 @@ void
mrb_init_proc(mrb_state *mrb)
{
struct RProc *m;
- mrb_code *call_iseq = mrb_malloc(mrb, sizeof(mrb_code));
- mrb_irep *call_irep = mrb_calloc(mrb, sizeof(mrb_irep), 1);
+ mrb_code *call_iseq = (mrb_code *)mrb_malloc(mrb, sizeof(mrb_code));
+ mrb_irep *call_irep = (mrb_irep *)mrb_calloc(mrb, sizeof(mrb_irep), 1);
if ( call_iseq == NULL || call_irep == NULL )
return;
View
@@ -43,7 +43,7 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl)
struct RRange *r;
r = (struct RRange*)mrb_obj_alloc(mrb, MRB_TT_RANGE, RANGE_CLASS);
- r->edges = mrb_malloc(mrb, sizeof(struct mrb_range_edges));
+ r->edges = (struct mrb_range_edges *)mrb_malloc(mrb, sizeof(struct mrb_range_edges));
range_check(mrb, beg, end);
r->edges->beg = beg;
r->edges->end = end;
Oops, something went wrong.

0 comments on commit 5a4beee

Please sign in to comment.