# endif
return NULL;
}
- BCOPY(str, copy, len);
+ if (len > 0)
+ BCOPY(str, copy, len);
copy[len] = '\0';
return copy;
}
# else
old_sz = ((oh *)base) -> oh_sz;
# endif
- BCOPY(p, result, old_sz < lb ? old_sz : lb);
+ if (old_sz > 0)
+ BCOPY(p, result, old_sz < lb ? old_sz : lb);
GC_debug_free(p);
}
return(result);
NORMAL);
if (NULL == new_array)
return FALSE;
- BCOPY(GC_toggleref_arr, new_array,
- GC_toggleref_array_size * sizeof(GCToggleRef));
+ if (EXPECT(GC_toggleref_array_size > 0, TRUE))
+ BCOPY(GC_toggleref_arr, new_array,
+ GC_toggleref_array_size * sizeof(GCToggleRef));
GC_INTERNAL_FREE(GC_toggleref_arr);
GC_toggleref_arr = new_array;
}
errno = ENOMEM;
return NULL;
}
- BCOPY(str, copy, len);
+ if (EXPECT(len > 0, TRUE))
+ BCOPY(str, copy, len);
copy[len] = '\0';
return copy;
}
/* Its unnecessary to clear the mark bit. If the */
/* object is reallocated, it doesn't matter. O.w. the */
/* collector will do it, since it's on a free list. */
- if (ok -> ok_init) {
+ if (ok -> ok_init && EXPECT(sz > sizeof(word), TRUE)) {
BZERO((word *)p + 1, sz-sizeof(word));
}
flh = &(ok -> ok_freelist[ngranules]);
GC_bytes_freed += sz;
if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= sz;
- if (ok -> ok_init) {
+ if (ok -> ok_init && EXPECT(sz > sizeof(word), TRUE)) {
BZERO((word *)p + 1, sz-sizeof(word));
}
flh = &(ok -> ok_freelist[ngranules]);
# endif
return NULL;
}
- BCOPY(str, copy, len);
+ if (EXPECT(len > 0, TRUE))
+ BCOPY(str, copy, len);
copy[len] = '\0';
return copy;
}
memset((char *)pstats + sizeof(stats), 0xff, stats_sz - sizeof(stats));
return sizeof(stats);
} else {
- BCOPY(&stats, pstats, stats_sz);
+ if (EXPECT(stats_sz > 0, TRUE))
+ BCOPY(&stats, pstats, stats_sz);
return stats_sz;
}
}
stats_sz - sizeof(stats));
return sizeof(stats);
} else {
- fill_prof_stats(&stats);
- BCOPY(&stats, pstats, stats_sz);
+ if (EXPECT(stats_sz > 0, TRUE)) {
+ fill_prof_stats(&stats);
+ BCOPY(&stats, pstats, stats_sz);
+ }
return stats_sz;
}
}
# endif
GC_STATIC_ASSERT(sizeof(struct callinfo) == sizeof(void *));
npcs = backtrace((void **)tmp_info, NFRAMES + IGNORE_FRAMES);
- BCOPY(tmp_info+IGNORE_FRAMES, info, (npcs - IGNORE_FRAMES) * sizeof(void *));
+ if (npcs > IGNORE_FRAMES)
+ BCOPY(&tmp_info[IGNORE_FRAMES], info,
+ (npcs - IGNORE_FRAMES) * sizeof(void *));
for (i = npcs - IGNORE_FRAMES; i < NFRAMES; ++i) info[i].ci_pc = 0;
# ifdef REDIRECT_MALLOC
GC_in_save_callers = FALSE;
have_errors = GC_have_errors;
printing_errors = TRUE;
n_leaked = GC_n_leaked;
- GC_ASSERT(n_leaked <= MAX_LEAKED);
- BCOPY(GC_leaked, leaked, n_leaked * sizeof(ptr_t));
- GC_n_leaked = 0;
- BZERO(GC_leaked, n_leaked * sizeof(ptr_t));
+ if (n_leaked > 0) {
+ GC_ASSERT(n_leaked <= MAX_LEAKED);
+ BCOPY(GC_leaked, leaked, n_leaked * sizeof(ptr_t));
+ GC_n_leaked = 0;
+ BZERO(GC_leaked, n_leaked * sizeof(ptr_t));
+ }
UNLOCK();
if (GC_debugging_started) {