* remove checks for x<0 when x is unsigned
* change void* pointer arithmetic to char* * make some gc functions consistent svn: r16368
This commit is contained in:
parent
0385b2f89d
commit
194e496e13
|
@ -103,7 +103,7 @@ inline static void *alloc_cache_find_pages(FreeBlock *blockfree, size_t len, siz
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alloc_cache_return_mem(VM *vm, void *p, size_t len, int zeroed)
|
static void alloc_cache_return_mem(VM *vm, char *p, size_t len, int zeroed)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FreeBlock *blockfree = vm->freeblocks;
|
FreeBlock *blockfree = vm->freeblocks;
|
||||||
|
@ -186,7 +186,7 @@ static void vm_flush_freed_pages(VM *vm)
|
||||||
|
|
||||||
static void *vm_malloc_pages(VM *vm, size_t len, size_t alignment, int dirty_ok)
|
static void *vm_malloc_pages(VM *vm, size_t len, size_t alignment, int dirty_ok)
|
||||||
{
|
{
|
||||||
void *r;
|
char *r;
|
||||||
FreeBlock *blockfree = vm->freeblocks;
|
FreeBlock *blockfree = vm->freeblocks;
|
||||||
|
|
||||||
if (!page_size)
|
if (!page_size)
|
||||||
|
@ -206,7 +206,7 @@ static void *vm_malloc_pages(VM *vm, size_t len, size_t alignment, int dirty_ok)
|
||||||
if (alignment) {
|
if (alignment) {
|
||||||
/* We allocated too large so we can choose the alignment. */
|
/* We allocated too large so we can choose the alignment. */
|
||||||
size_t extra = alignment;
|
size_t extra = alignment;
|
||||||
void *real_r = (void *)(((unsigned long)r + (alignment - 1)) & (~(alignment - 1)));
|
char *real_r = (char*)(((unsigned long)r + (alignment - 1)) & (~(alignment - 1)));
|
||||||
long pre_extra = real_r - r;
|
long pre_extra = real_r - r;
|
||||||
|
|
||||||
/* in front extra */
|
/* in front extra */
|
||||||
|
|
|
@ -183,7 +183,8 @@ void GC_set_collect_inform_callback(void (*func)(int major_gc, long pre_used, lo
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void garbage_collect(NewGC*, int);
|
static void garbage_collect(NewGC*, int);
|
||||||
|
|
||||||
static void out_of_memory()
|
/* do not use the gc parameter or check if its NULL in the future */
|
||||||
|
static void out_of_memory(NewGC* gc)
|
||||||
{
|
{
|
||||||
if (GC_report_out_of_memory)
|
if (GC_report_out_of_memory)
|
||||||
GC_report_out_of_memory();
|
GC_report_out_of_memory();
|
||||||
|
@ -193,7 +194,7 @@ static void out_of_memory()
|
||||||
|
|
||||||
static void *ofm_malloc(size_t size) {
|
static void *ofm_malloc(size_t size) {
|
||||||
void *ptr = malloc(size);
|
void *ptr = malloc(size);
|
||||||
if (!ptr) out_of_memory();
|
if (!ptr) out_of_memory(NULL);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ inline static void check_used_against_max(NewGC *gc, size_t len)
|
||||||
gc->used_pages -= delta;
|
gc->used_pages -= delta;
|
||||||
GC_out_of_memory();
|
GC_out_of_memory();
|
||||||
}
|
}
|
||||||
out_of_memory();
|
out_of_memory(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +245,7 @@ static void *malloc_pages(NewGC *gc, size_t len, size_t alignment)
|
||||||
void *ptr;
|
void *ptr;
|
||||||
check_used_against_max(gc, len);
|
check_used_against_max(gc, len);
|
||||||
ptr = vm_malloc_pages(gc->vm, len, alignment, 0);
|
ptr = vm_malloc_pages(gc->vm, len, alignment, 0);
|
||||||
if (!ptr) out_of_memory();
|
if (!ptr) out_of_memory(NULL);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ static void *malloc_dirty_pages(NewGC *gc, size_t len, size_t alignment)
|
||||||
void *ptr;
|
void *ptr;
|
||||||
check_used_against_max(gc, len);
|
check_used_against_max(gc, len);
|
||||||
ptr = vm_malloc_pages(gc->vm, len, alignment, 1);
|
ptr = vm_malloc_pages(gc->vm, len, alignment, 1);
|
||||||
if (!ptr) out_of_memory();
|
if (!ptr) out_of_memory(NULL);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +702,7 @@ static void *allocate_medium(const size_t request_size_bytes, const int type)
|
||||||
inline static mpage *gen0_create_new_mpage(NewGC *gc) {
|
inline static mpage *gen0_create_new_mpage(NewGC *gc) {
|
||||||
mpage *newmpage;
|
mpage *newmpage;
|
||||||
|
|
||||||
newmpage = malloc_mpage(gc);
|
newmpage = malloc_mpage();
|
||||||
newmpage->addr = malloc_dirty_pages(gc, GEN0_PAGE_SIZE, APAGE_SIZE);
|
newmpage->addr = malloc_dirty_pages(gc, GEN0_PAGE_SIZE, APAGE_SIZE);
|
||||||
newmpage->size_class = 0;
|
newmpage->size_class = 0;
|
||||||
newmpage->size = PREFIX_SIZE;
|
newmpage->size = PREFIX_SIZE;
|
||||||
|
|
|
@ -15,7 +15,7 @@ static inline size_t vm_round_up_to_page_size(size_t len, size_t page_size) {
|
||||||
|
|
||||||
#if !( defined(_WIN32) || defined(OSKIT) )
|
#if !( defined(_WIN32) || defined(OSKIT) )
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *start;
|
char *start;
|
||||||
long len;
|
long len;
|
||||||
short age;
|
short age;
|
||||||
short zeroed;
|
short zeroed;
|
||||||
|
|
|
@ -269,8 +269,7 @@ Scheme_Object *scheme_make_char(mzchar ch)
|
||||||
|
|
||||||
Scheme_Object *scheme_make_char_or_nul(mzchar v)
|
Scheme_Object *scheme_make_char_or_nul(mzchar v)
|
||||||
{
|
{
|
||||||
if ((v >= 0)
|
if ((v <= 0x10FFFF)
|
||||||
&& (v <= 0x10FFFF)
|
|
||||||
&& ((v < 0xD800) || (v > 0xDFFF)))
|
&& ((v < 0xD800) || (v > 0xDFFF)))
|
||||||
return scheme_make_char(v);
|
return scheme_make_char(v);
|
||||||
|
|
||||||
|
|
|
@ -1734,6 +1734,8 @@ static Scheme_Object *bytes_to_integer (int argc, Scheme_Object *argv[])
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* throw an error here */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MZ_U8HI 0
|
#define MZ_U8HI 0
|
||||||
|
|
|
@ -2774,7 +2774,6 @@ static char *locale_recase(int to_up,
|
||||||
s = in XFORM_OK_PLUS id;
|
s = in XFORM_OK_PLUS id;
|
||||||
wl = mz_mbsnrtowcs(NULL, &s, iilen, 0, &state);
|
wl = mz_mbsnrtowcs(NULL, &s, iilen, 0, &state);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (wl < 0) return NULL;
|
|
||||||
|
|
||||||
/* Allocate space */
|
/* Allocate space */
|
||||||
if (wl < MZ_WC_BUF_SIZE) {
|
if (wl < MZ_WC_BUF_SIZE) {
|
||||||
|
@ -2788,7 +2787,6 @@ static char *locale_recase(int to_up,
|
||||||
s = in XFORM_OK_PLUS id;
|
s = in XFORM_OK_PLUS id;
|
||||||
wl2 = mz_mbsnrtowcs(wc, &s, iilen, wl + 1, &state);
|
wl2 = mz_mbsnrtowcs(wc, &s, iilen, wl + 1, &state);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (wl2 < 0) return NULL; /* Very strange! */
|
|
||||||
|
|
||||||
wc[wl] = 0; /* just in case */
|
wc[wl] = 0; /* just in case */
|
||||||
|
|
||||||
|
@ -2813,7 +2811,6 @@ static char *locale_recase(int to_up,
|
||||||
ws = wc;
|
ws = wc;
|
||||||
ml = mz_wcsnrtombs(NULL, (const wchar_t **)&ws, wl, 0, &state);
|
ml = mz_wcsnrtombs(NULL, (const wchar_t **)&ws, wl, 0, &state);
|
||||||
ws = NULL;
|
ws = NULL;
|
||||||
if (ml < 0) return NULL;
|
|
||||||
|
|
||||||
/* Allocate space */
|
/* Allocate space */
|
||||||
*oolen = ml;
|
*oolen = ml;
|
||||||
|
@ -2827,7 +2824,6 @@ static char *locale_recase(int to_up,
|
||||||
ws = wc;
|
ws = wc;
|
||||||
ml2 = mz_wcsnrtombs(out + od, (const wchar_t **)&ws, wl, ml + 1, &state);
|
ml2 = mz_wcsnrtombs(out + od, (const wchar_t **)&ws, wl, ml + 1, &state);
|
||||||
ws = NULL;
|
ws = NULL;
|
||||||
if (ml2 < 0) return NULL; /* Very strange! */
|
|
||||||
|
|
||||||
out[od + ml] = 0;
|
out[od + ml] = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user