aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/grammar.cpp11
-rw-r--r--engines/sci/engine/kernel.cpp2
-rw-r--r--engines/sci/engine/kgraphics.cpp2
-rw-r--r--engines/sci/engine/kmenu.cpp2
-rw-r--r--engines/sci/engine/kpathing.cpp2
-rw-r--r--engines/sci/engine/kscripts.cpp2
-rw-r--r--engines/sci/engine/kstring.cpp2
-rw-r--r--engines/sci/engine/said.cpp2
-rw-r--r--engines/sci/engine/said.y2
-rw-r--r--engines/sci/engine/savegame.cpp9
-rw-r--r--engines/sci/engine/scriptconsole.cpp7
-rw-r--r--engines/sci/engine/scriptdebug.cpp8
-rw-r--r--engines/sci/engine/seg_manager.cpp18
-rw-r--r--engines/sci/gfx/gfx_gui.cpp2
-rw-r--r--engines/sci/gfx/gfx_pixmap_scale.cpp10
-rw-r--r--engines/sci/gfx/gfx_resmgr.cpp10
-rw-r--r--engines/sci/gfx/gfx_system.h1
-rw-r--r--engines/sci/gfx/gfx_test.cpp20
-rw-r--r--engines/sci/gfx/gfx_tools.cpp15
-rw-r--r--engines/sci/gfx/gfx_widgets.cpp3
-rw-r--r--engines/sci/gfx/menubar.cpp3
-rw-r--r--engines/sci/gfx/operations.cpp1
-rw-r--r--engines/sci/gfx/res_font.cpp7
-rw-r--r--engines/sci/gfx/res_pal.cpp1
-rw-r--r--engines/sci/gfx/res_pic.cpp7
-rw-r--r--engines/sci/gfx/res_view0.cpp7
-rw-r--r--engines/sci/gfx/res_view1.cpp11
-rw-r--r--engines/sci/module.mk1
-rw-r--r--engines/sci/sci_memory.cpp98
-rw-r--r--engines/sci/sci_memory.h80
-rw-r--r--engines/sci/scicore/resource.cpp1
-rw-r--r--engines/sci/scicore/sciconsole.cpp3
-rw-r--r--engines/sci/scicore/vocab_debug.cpp8
-rw-r--r--engines/sci/scicore/vocabulary.cpp2
-rw-r--r--engines/sci/sfx/iterator.cpp1
-rw-r--r--engines/sci/sfx/seq/instrument-map.cpp13
-rw-r--r--engines/sci/sfx/softseq/amiga.cpp7
-rw-r--r--engines/sci/sfx/songlib.cpp3
38 files changed, 91 insertions, 293 deletions
diff --git a/engines/sci/engine/grammar.cpp b/engines/sci/engine/grammar.cpp
index 0d07169449..d4483045cc 100644
--- a/engines/sci/engine/grammar.cpp
+++ b/engines/sci/engine/grammar.cpp
@@ -31,7 +31,6 @@
#include "sci/tools.h"
#include "sci/scicore/vocabulary.h"
#include "sci/scicore/sciconsole.h"
-#include "sci/sci_memory.h"
namespace Sci {
@@ -104,7 +103,7 @@ static void _vfree(parse_rule_t *rule) {
}
static parse_rule_t *_vdup(parse_rule_t *a) {
- parse_rule_t *rule = (parse_rule_t*)sci_malloc(sizeof(int) * (a->length + 4));
+ parse_rule_t *rule = (parse_rule_t*)malloc(sizeof(int) * (a->length + 4));
rule->id = a->id;
rule->length = a->length;
@@ -127,7 +126,7 @@ static parse_rule_t *_vinsert(parse_rule_t *turkey, parse_rule_t *stuffing) {
if ((firstnt == turkey->length) || (turkey->data[firstnt] != stuffing->id))
return NULL;
- rule = (parse_rule_t*)sci_malloc(sizeof(int) * (turkey->length - 1 + stuffing->length + 4));
+ rule = (parse_rule_t*)malloc(sizeof(int) * (turkey->length - 1 + stuffing->length + 4));
rule->id = turkey->id;
rule->specials_nr = turkey->specials_nr + stuffing->specials_nr - 1;
rule->first_special = firstnt + stuffing->first_special;
@@ -160,7 +159,7 @@ static parse_rule_t *_vbuild_rule(const parse_tree_branch_t *branch) {
return NULL; // invalid
}
- rule = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + tokens));
+ rule = (parse_rule_t*)malloc(sizeof(int) * (4 + tokens));
++_allocd_rules;
rule->id = branch->id;
@@ -205,7 +204,7 @@ static parse_rule_t *_vsatisfy_rule(parse_rule_t *rule, const ResultWord &input)
if (((dep & TOKEN_TERMINAL_CLASS) && ((dep & 0xffff) & input._class)) ||
((dep & TOKEN_TERMINAL_GROUP) && ((dep & 0xffff) & input._group))) {
- parse_rule_t *retval = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + rule->length));
+ parse_rule_t *retval = (parse_rule_t*)malloc(sizeof(int) * (4 + rule->length));
++_allocd_rules;
retval->id = rule->id;
retval->specials_nr = rule->specials_nr - 1;
@@ -251,7 +250,7 @@ static parse_rule_list_t *_vocab_add_rule(parse_rule_list_t *list, parse_rule_t
if (!rule)
return list;
- new_elem = (parse_rule_list_t*)sci_malloc(sizeof(parse_rule_list_t));
+ new_elem = (parse_rule_list_t*)malloc(sizeof(parse_rule_list_t));
term = rule->data[rule->first_special];
new_elem->rule = rule;
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index a507a2b89a..cf74293763 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -518,7 +518,7 @@ void kernel_compile_signature(const char **s) {
if (!src)
return; // NULL signature: Nothing to do
- result = (char*)sci_malloc(strlen(*s) + 1);
+ result = (char*)malloc(strlen(*s) + 1);
while (*src) {
char c;
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index abf2fc8fdb..e3a8fc9565 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -1655,7 +1655,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
if (entries_nr) { // determine list_top, selection, and the entries_list
seeker = text;
- entries_list = (char**)sci_malloc(sizeof(char *) * entries_nr);
+ entries_list = (char**)malloc(sizeof(char *) * entries_nr);
for (i = 0; i < entries_nr; i++) {
entries_list[i] = seeker;
seeker += entry_size ;
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index 4cb89ef128..b241c68bc8 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -77,7 +77,7 @@ reg_t kDrawStatus(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->status_bar_background = bgcolor;
if (text.segment) {
- const char *tmp = sci_strdup(kernel_dereference_char_pointer(s, text, 0));
+ const char *tmp = strdup(kernel_dereference_char_pointer(s, text, 0));
s->_statusBarText = tmp ? tmp : "";
}
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index 89fb58d0ff..d01ff1bc29 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -1448,7 +1448,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co
}
// Allocate and build vertex index
- pf_s->vertex_index = (Vertex**)sci_malloc(sizeof(Vertex *) * (count + 2));
+ pf_s->vertex_index = (Vertex**)malloc(sizeof(Vertex *) * (count + 2));
count = 0;
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 0477430dbb..4a71f231ae 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -179,7 +179,7 @@ reg_t kClone(EngineState *s, int funct_nr, int argc, reg_t *argv) {
memcpy(clone_obj, parent_obj, sizeof(Clone));
clone_obj->flags = 0;
varblock_size = parent_obj->variables_nr * sizeof(reg_t);
- clone_obj->variables = (reg_t*)sci_malloc(varblock_size);
+ clone_obj->variables = (reg_t*)malloc(varblock_size);
memcpy(clone_obj->variables, parent_obj->variables, varblock_size);
// Mark as clone
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 046c8a8419..bda82e1329 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -505,7 +505,7 @@ reg_t kFormat(EngineState *s, int funct_nr, int argc, reg_t *argv) {
SCIkdebug(SCIkSTRINGS, "Formatting \"%s\"\n", source);
- arguments = (int*)sci_malloc(sizeof(int) * argc);
+ arguments = (int*)malloc(sizeof(int) * argc);
#ifdef SATISFY_PURIFY
memset(arguments, 0, sizeof(int) * argc);
#endif
diff --git a/engines/sci/engine/said.cpp b/engines/sci/engine/said.cpp
index f261454b55..f7bfff2061 100644
--- a/engines/sci/engine/said.cpp
+++ b/engines/sci/engine/said.cpp
@@ -209,7 +209,7 @@ static tree_t said_terminal(int);
static int yylex(void);
static int yyerror(const char *s) {
- said_parse_error = sci_strdup(s);
+ said_parse_error = strdup(s);
return 1; /* Abort */
}
diff --git a/engines/sci/engine/said.y b/engines/sci/engine/said.y
index 6924da16e0..ecea28d848 100644
--- a/engines/sci/engine/said.y
+++ b/engines/sci/engine/said.y
@@ -102,7 +102,7 @@ static tree_t said_terminal(int);
static int yylex(void);
static int yyerror(const char *s) {
- said_parse_error = sci_strdup(s);
+ said_parse_error = strdup(s);
return 1; /* Abort */
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 544f918468..2e2bd66322 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -31,7 +31,6 @@
#include <time.h> // FIXME: For struct tm
-#include "sci/sci_memory.h"
#include "sci/gfx/operations.h"
#include "sci/gfx/menubar.h"
#include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxContainer
@@ -271,7 +270,7 @@ static void sync_LocalVariables(Common::Serializer &s, LocalVariables &obj) {
s.syncAsSint32LE(obj.nr);
if (!obj.locals && obj.nr)
- obj.locals = (reg_t *)sci_calloc(obj.nr, sizeof(reg_t));
+ obj.locals = (reg_t *)calloc(obj.nr, sizeof(reg_t));
for (int i = 0; i < obj.nr; ++i)
sync_reg_t(s, obj.locals[i]);
}
@@ -285,7 +284,7 @@ void syncWithSerializer(Common::Serializer &s, Object &obj) {
s.syncAsSint32LE(obj.variables_nr);
if (!obj.variables && obj.variables_nr)
- obj.variables = (reg_t *)sci_calloc(obj.variables_nr, sizeof(reg_t));
+ obj.variables = (reg_t *)calloc(obj.variables_nr, sizeof(reg_t));
for (int i = 0; i < obj.variables_nr; ++i)
sync_reg_t(s, obj.variables[i]);
}
@@ -368,7 +367,7 @@ static void sync_DynMem(Common::Serializer &s, DynMem &obj) {
s.syncAsSint32LE(obj._size);
syncCStr(s, &obj._description);
if (!obj._buf && obj._size) {
- obj._buf = (byte *)sci_calloc(obj._size, 1);
+ obj._buf = (byte *)calloc(obj._size, 1);
}
if (obj._size)
s.syncBytes(obj._buf, obj._size);
@@ -378,7 +377,7 @@ static void sync_DataStack(Common::Serializer &s, DataStack &obj) {
s.syncAsUint32LE(obj.nr);
if (s.isLoading()) {
//free(obj.entries);
- obj.entries = (reg_t *)sci_calloc(obj.nr, sizeof(reg_t));
+ obj.entries = (reg_t *)calloc(obj.nr, sizeof(reg_t));
}
}
diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp
index 6ba2afcf1c..577433371c 100644
--- a/engines/sci/engine/scriptconsole.cpp
+++ b/engines/sci/engine/scriptconsole.cpp
@@ -26,7 +26,6 @@
/* Second half of the console implementation: VM dependent stuff */
/* Remember, it doesn't have to be fast. */
-#include "sci/sci_memory.h"
#include "sci/engine/state.h"
#include "sci/scicore/sciconsole.h"
@@ -160,7 +159,7 @@ void con_init() {
cmd_mm[i].size_per_entry = cmd_mm_sizes_per_entry[i];
cmd_mm[i].entries = 0;
cmd_mm[i].allocated = CMD_MM_DEFAULT_ALLOC;
- cmd_mm[i].data = sci_calloc(cmd_mm[i].allocated, cmd_mm[i].size_per_entry);
+ cmd_mm[i].data = calloc(cmd_mm[i].allocated, cmd_mm[i].size_per_entry);
cmd_mm[i].print = cmd_mm_printers[i];
}
@@ -398,7 +397,7 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on
}
void con_parse(EngineState *s, const char *command) {
- char *cmd = (command && command[0]) ? (char *)sci_strdup(command) : (char *)sci_strdup(" ");
+ char *cmd = (command && command[0]) ? (char *)strdup(command) : (char *)strdup(" ");
char *_cmd = cmd;
int pos = 0;
@@ -882,7 +881,7 @@ static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams
}
seeklen = cmdParams.size() - 1;
- seekstr = (unsigned char *)sci_malloc(seeklen);
+ seekstr = (unsigned char *)malloc(seeklen);
if (NULL == seekstr) {
fprintf(stderr, "console.c: c_hexgrep(): malloc failed for seekstr\r\n");
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 3a23c26324..4ea47c8710 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -2312,7 +2312,7 @@ const generic_config_flag_t SCIk_Debug_Names[SCIk_DEBUG_MODES] = {
} ;
void set_debug_mode(EngineState *s, int mode, const char *areas) {
- char *param = (char*)sci_malloc(strlen(areas) + 2);
+ char *param = (char*)malloc(strlen(areas) + 2);
param[0] = (mode) ? '+' : '-';
strcpy(param + 1, areas);
@@ -2583,10 +2583,10 @@ static Breakpoint *bp_alloc(EngineState *s) {
bp = s->bp_list;
while (bp->next)
bp = bp->next;
- bp->next = (Breakpoint *)sci_malloc(sizeof(Breakpoint));
+ bp->next = (Breakpoint *)malloc(sizeof(Breakpoint));
bp = bp->next;
} else {
- s->bp_list = (Breakpoint *)sci_malloc(sizeof(Breakpoint));
+ s->bp_list = (Breakpoint *)malloc(sizeof(Breakpoint));
bp = s->bp_list;
}
@@ -2605,7 +2605,7 @@ int c_bpx(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
bp = bp_alloc(s);
bp->type = BREAK_SELECTOR;
- bp->data.name = (char *)sci_malloc(strlen(cmdParams [0].str) + 1);
+ bp->data.name = (char *)malloc(strlen(cmdParams [0].str) + 1);
strcpy(bp->data.name, cmdParams [0].str);
s->have_bp |= BREAK_SELECTOR;
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 6e80133351..9ca5a9cd80 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -175,7 +175,7 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) {
// allocate the script.buf
setScriptSize(scr, s, script_nr);
- scr.buf = (byte *)sci_malloc(scr.buf_size);
+ scr.buf = (byte *)malloc(scr.buf_size);
dbgPrint("scr.buf ", scr.buf);
if (!scr.buf) {
@@ -672,7 +672,7 @@ Object *SegManager::scriptObjInit0(EngineState *s, reg_t obj_pos) {
+ (is_class ? functions_nr * 2 : 0) < scr->buf_size, "Function area extends beyond end of script");
obj->variables_nr = variables_nr;
- obj->variables = (reg_t *)sci_malloc(sizeof(reg_t) * variables_nr);
+ obj->variables = (reg_t *)malloc(sizeof(reg_t) * variables_nr);
obj->methods_nr = functions_nr;
obj->base = scr->buf;
@@ -729,7 +729,7 @@ Object *SegManager::scriptObjInit11(EngineState *s, reg_t obj_pos) {
obj->variables_nr = variables_nr;
obj->variable_names_nr = variables_nr;
- obj->variables = (reg_t *)sci_malloc(sizeof(reg_t) * variables_nr);
+ obj->variables = (reg_t *)malloc(sizeof(reg_t) * variables_nr);
obj->methods_nr = functions_nr;
obj->base = scr->buf;
@@ -768,7 +768,7 @@ LocalVariables *SegManager::allocLocalsSegment(Script *scr, int count) {
locals = scr->locals_block = (LocalVariables *)mobj;
locals->script_id = scr->nr;
- locals->locals = (reg_t *)sci_calloc(count, sizeof(reg_t));
+ locals->locals = (reg_t *)calloc(count, sizeof(reg_t));
locals->nr = count;
return locals;
@@ -879,7 +879,7 @@ void SegManager::scriptInitialiseObjectsSci11(EngineState *s, int seg) {
/*
static char *SegManager::dynprintf(char *msg, ...) {
va_list argp;
- char *buf = (char *)sci_malloc(strlen(msg) + 100);
+ char *buf = (char *)malloc(strlen(msg) + 100);
va_start(argp, msg);
vsprintf(buf, msg, argp);
@@ -893,7 +893,7 @@ DataStack *SegManager::allocateStack(int size, SegmentId *segid) {
MemObject *mobj = allocNonscriptSegment(MEM_OBJ_STACK, segid);
DataStack *retval = (DataStack *)mobj;
- retval->entries = (reg_t *)sci_calloc(size, sizeof(reg_t));
+ retval->entries = (reg_t *)calloc(size, sizeof(reg_t));
retval->nr = size;
return retval;
@@ -943,7 +943,7 @@ Hunk *SegManager::alloc_hunk_entry(const char *hunk_type, int size, reg_t *reg)
if (!h)
return NULL;
- h->mem = sci_malloc(size);
+ h->mem = malloc(size);
h->size = size;
h->type = hunk_type;
@@ -1093,9 +1093,9 @@ unsigned char *SegManager::allocDynmem(int size, const char *descr, reg_t *addr)
if (size == 0)
d._buf = NULL;
else
- d._buf = (byte *)sci_malloc(size);
+ d._buf = (byte *)malloc(size);
- d._description = sci_strdup(descr);
+ d._description = strdup(descr);
return (unsigned char *)(d._buf);
}
diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp
index e76d8feb12..70ff0faf7d 100644
--- a/engines/sci/gfx/gfx_gui.cpp
+++ b/engines/sci/gfx/gfx_gui.cpp
@@ -366,7 +366,7 @@ GfxList *sciw_new_edit_control(GfxPort *port, reg_t ID, rect_t zone, char *text,
list->add(GFXWC(list), text_handle);
} else {
- char *textdup = (char *)sci_malloc(strlen(text) + 1);
+ char *textdup = (char *)malloc(strlen(text) + 1);
strncpy(textdup, text, cursor);
diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp
index 9173db5e7c..d13c0d143e 100644
--- a/engines/sci/gfx/gfx_pixmap_scale.cpp
+++ b/engines/sci/gfx/gfx_pixmap_scale.cpp
@@ -65,7 +65,7 @@ void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale
assert(bytespp == COPY_BYTES);
if (separate_alpha_map && !alpha_dest)
- alpha_dest = pxm->alpha_map = (byte *)sci_malloc(pxm->index_width * xfact * pxm->index_height * yfact);
+ alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * xfact * pxm->index_height * yfact);
// Calculate all colors
for (i = 0; i < pxm->colors_nr(); i++) {
@@ -227,7 +227,7 @@ void _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {
shifts[3] = mode->alpha_shift;
if (separate_alpha_map && !alpha_dest)
- alpha_dest = pxm->alpha_map = (byte *)sci_malloc(pxm->index_width * xfact * pxm->index_height * yfact);
+ alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * xfact * pxm->index_height * yfact);
for (y = 0; y < pxm->index_height; y++) {
byte *linepos = dest;
@@ -380,7 +380,7 @@ void _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale)
return;
if (separate_alpha_map && !alpha_dest)
- alpha_dest = pxm->alpha_map = (byte *)sci_malloc(pxm->index_width * xfact * pxm->index_height * yfact);
+ alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * xfact * pxm->index_height * yfact);
src -= pxm->index_width + 1;
@@ -614,13 +614,13 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t fi
if (!pxm->data) {
- pxm->data = (byte*)sci_malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height * mode->bytespp + 1);
+ pxm->data = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height * mode->bytespp + 1);
// +1: Eases coying on BE machines in 24 bpp packed mode
// Assume that memory, if allocated already, will be sufficient
// Allocate alpha map
if (!mode->alpha_mask && pxm->colors_nr() < GFX_PIC_COLORS)
- pxm->alpha_map = (byte*)sci_malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1);
+ pxm->alpha_map = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1);
} else
was_allocated = 1;
diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp
index 6866f32be6..35b71236b9 100644
--- a/engines/sci/gfx/gfx_resmgr.cpp
+++ b/engines/sci/gfx/gfx_resmgr.cpp
@@ -118,7 +118,7 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic
gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic);
if (!scaled_pic->undithered_buffer)
- scaled_pic->undithered_buffer = sci_malloc(scaled_pic->undithered_buffer_size);
+ scaled_pic->undithered_buffer = malloc(scaled_pic->undithered_buffer_size);
memcpy(scaled_pic->undithered_buffer, scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer_size);
@@ -359,7 +359,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale
return NULL;
}
if (!res) {
- res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
+ res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num);
#ifdef CUSTOM_GRAPHICS_OPTIONS
res->lock_sequence_nr = _options->buffer_pics_nr;
@@ -548,7 +548,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
}
if (!res) {
- res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
+ res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->scaled_data.view = NULL;
res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr);
res->lock_sequence_nr = _tagLockCounter;
@@ -619,7 +619,7 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {
gfx_bitmap_font_t *font = gfxr_read_font(fontRes->id, fontRes->data, fontRes->size);
if (!res) {
- res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
+ res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->scaled_data.font = NULL;
res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_FONT, num);
res->lock_sequence_nr = _tagLockCounter;
@@ -665,7 +665,7 @@ gfx_pixmap_t *GfxResManager::getCursor(int num) {
return NULL;
if (!res) {
- res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
+ res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->scaled_data.pointer = NULL;
res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, num);
res->lock_sequence_nr = _tagLockCounter;
diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h
index a698c77f22..beb23b5db1 100644
--- a/engines/sci/gfx/gfx_system.h
+++ b/engines/sci/gfx/gfx_system.h
@@ -28,7 +28,6 @@
#include "common/scummsys.h"
#include "common/rect.h"
-#include "sci/sci_memory.h"
#include "sci/tools.h"
#include "sci/gfx/palette.h"
diff --git a/engines/sci/gfx/gfx_test.cpp b/engines/sci/gfx/gfx_test.cpp
index a3c24159e7..a5f57df315 100644
--- a/engines/sci/gfx/gfx_test.cpp
+++ b/engines/sci/gfx/gfx_test.cpp
@@ -70,10 +70,6 @@ void *memdup(void *mem, size_t size) {
return r;
}
-#ifdef FREESCI_PRIMARY_RESOURCE_H_
-# include "../scicore/sci_memory.c"
-#endif
-
void sci_gettime(long *seconds, long *useconds) {
struct timeval tv;
@@ -178,7 +174,7 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_opt
int *arrdup(int *src, int count) {
- int *retval = sci_malloc(sizeof(int) * count);
+ int *retval = malloc(sizeof(int) * count);
memcpy(retval, src, sizeof(int) * count);
return retval;
}
@@ -221,7 +217,7 @@ gfx_pixmap_color_t pic_colors[PIC_COLORS_NR] = {
};
gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) {
- gfxr_pic_t *pic = sci_malloc(sizeof(gfxr_pic_t));
+ gfxr_pic_t *pic = malloc(sizeof(gfxr_pic_t));
pic->mode = mode;
pic->undithered_buffer = NULL;
@@ -338,7 +334,7 @@ gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *inte
if (nr < 0 || nr > TEST_VIEWS_NR)
return NULL;
- view = sci_malloc(sizeof(gfxr_view_t));
+ view = malloc(sizeof(gfxr_view_t));
view->ID = nr | 2048;
view->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
@@ -346,10 +342,10 @@ gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *inte
view->colors = view_colors;
view->loops_nr = 1;
- view->loops = loop = sci_malloc(sizeof(gfxr_loop_t));
+ view->loops = loop = malloc(sizeof(gfxr_loop_t));
loop->cels_nr = 3;
- loop->cels = sci_malloc(sizeof(gfx_pixmap_t *) * loop->cels_nr);
+ loop->cels = malloc(sizeof(gfx_pixmap_t *) * loop->cels_nr);
for (i = 0; i < 3; i++) {
gfx_pixmap_t *pxm = gfx_pixmap_alloc_index_data(gfx_new_pixmap(16, 16, 2048 | nr, 0, i));
@@ -402,10 +398,10 @@ gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void
if (nr < 0 || nr > TEST_FONTS_NR)
return NULL;
- font = sci_malloc(sizeof(gfx_bitmap_font_t));
+ font = malloc(sizeof(gfx_bitmap_font_t));
font->ID = nr;
font->chars_nr = BUILTIN_CHARS_NR;
- font->widths = sci_malloc(sizeof(int) * BUILTIN_CHARS_NR);
+ font->widths = malloc(sizeof(int) * BUILTIN_CHARS_NR);
for (i = 0; i < BUILTIN_CHARS_NR; i++)
font->widths[i] = BUILTIN_CHARS_WIDTH;
font->row_size = (BUILTIN_CHARS_WIDTH + 7) >> 3;
@@ -1060,7 +1056,7 @@ int main(int argc, char **argv) {
case 'g':
if (driver) sci_free(driver);
- driver = sci_strdup(optarg);
+ driver = strdup(optarg);
break;
case 'l': {
diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp
index 4ac71c0459..ac6e3c022a 100644
--- a/engines/sci/gfx/gfx_tools.cpp
+++ b/engines/sci/gfx/gfx_tools.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_tools.h"
namespace Sci {
@@ -45,7 +44,7 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) {
}
gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, Palette *palette, int flags) {
- gfx_mode_t *mode = (gfx_mode_t *)sci_malloc(sizeof(gfx_mode_t));
+ gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t));
mode->xfact = xfact;
mode->yfact = yfact;
@@ -108,7 +107,7 @@ void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) {
}
gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) {
- gfx_pixmap_t *clone = (gfx_pixmap_t *)sci_malloc(sizeof(gfx_pixmap_t));
+ gfx_pixmap_t *clone = (gfx_pixmap_t *)malloc(sizeof(gfx_pixmap_t));
*clone = *pxm;
clone->index_data = NULL;
clone->palette = NULL;
@@ -117,7 +116,7 @@ gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) {
memcpy(clone->data, pxm->data, clone->data_size);
if (clone->alpha_map) {
- clone->alpha_map = (byte *) sci_malloc(clone->width * clone->height);
+ clone->alpha_map = (byte *) malloc(clone->width * clone->height);
memcpy(clone->alpha_map, pxm->alpha_map, clone->width * clone->height);
}
@@ -125,7 +124,7 @@ gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) {
}
gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) {
- gfx_pixmap_t *pxm = (gfx_pixmap_t *)sci_malloc(sizeof(gfx_pixmap_t));
+ gfx_pixmap_t *pxm = (gfx_pixmap_t *)malloc(sizeof(gfx_pixmap_t));
pxm->alpha_map = NULL;
pxm->data = NULL;
@@ -169,7 +168,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) {
if (!size)
size = 1;
- pixmap->index_data = (byte*)sci_malloc(size);
+ pixmap->index_data = (byte*)malloc(size);
memset(pixmap->index_data, 0, size);
@@ -207,7 +206,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {
if (!size)
size = 1;
- pixmap->data = (byte*)sci_malloc(pixmap->data_size = size);
+ pixmap->data = (byte*)malloc(pixmap->data_size = size);
return pixmap;
}
@@ -251,7 +250,7 @@ gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode
xl = pixmap->index_width;
yl = pixmap->index_height;
linewidth = xfact * xl;
- initial_new_data = new_data = (byte *)sci_malloc(linewidth * yfact * yl);
+ initial_new_data = new_data = (byte *)malloc(linewidth * yfact * yl);
for (yc = 0; yc < yl; yc++) {
diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp
index 71ff4d82ff..9252fa750d 100644
--- a/engines/sci/gfx/gfx_widgets.cpp
+++ b/engines/sci/gfx/gfx_widgets.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_gui.h" // for kWindowAutoRestore
#include "sci/gfx/gfx_widgets.h"
#include "sci/gfx/gfx_state_internal.h"
@@ -1754,7 +1753,7 @@ GfxWidget *gfxw_show_widget(GfxWidget *widget) {
}
gfxw_snapshot_t *gfxw_make_snapshot(GfxVisual *visual, rect_t area) {
- gfxw_snapshot_t *retval = (gfxw_snapshot_t*)sci_malloc(sizeof(gfxw_snapshot_t));
+ gfxw_snapshot_t *retval = (gfxw_snapshot_t*)malloc(sizeof(gfxw_snapshot_t));
retval->serial = widget_serial_number_counter++;
diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp
index 9237c9bb0c..f463b5c7c4 100644
--- a/engines/sci/gfx/menubar.cpp
+++ b/engines/sci/gfx/menubar.cpp
@@ -28,7 +28,6 @@
** used for any actual actions on behalf of the interpreter.
*/
-#include "sci/sci_memory.h"
#include "sci/engine/state.h"
#include "sci/gfx/menubar.h"
#include "sci/engine/kernel.h"
@@ -41,7 +40,7 @@ namespace Sci {
** Parameters: (char *) src: The source string
** (int) length: The maximum length of the string (not counting
** a trailing \0).
-** Returns : (char *) The resulting copy, allocated with sci_malloc().
+** Returns : (char *) The resulting copy, allocated with malloc().
** To free this string, use the free() command.
** See _SCI_MALLOC() for more information if call fails.
*/
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index 87b5d4e483..9646b29c73 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -25,7 +25,6 @@
// Graphical operations, called from the widget state manager
-#include "sci/sci_memory.h"
#include "sci/gfx/operations.h"
#include "sci/gfx/font.h"
#include "sci/sci.h" // for g_engine, evil hack
diff --git a/engines/sci/gfx/res_font.cpp b/engines/sci/gfx/res_font.cpp
index c208fe16f0..7330df7441 100644
--- a/engines/sci/gfx/res_font.cpp
+++ b/engines/sci/gfx/res_font.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
@@ -64,7 +63,7 @@ static int calc_char(byte *dest, int total_width, int total_height, byte *src, i
}
gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) {
- gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_calloc(sizeof(gfx_bitmap_font_t), 1);
+ gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)calloc(sizeof(gfx_bitmap_font_t), 1);
int chars_nr;
int max_width = 0, max_height;
int i;
@@ -96,7 +95,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) {
}
font->ID = id;
- font->widths = (int*)sci_malloc(sizeof(int) * chars_nr);
+ font->widths = (int*)malloc(sizeof(int) * chars_nr);
for (i = 0; i < chars_nr; i++) {
int offset = READ_LE_UINT16(resource + (i << 1) + 6);
@@ -125,7 +124,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) {
font->row_size = (font->row_size + 3) & ~3;
font->char_size = font->row_size * max_height;
- font->data = (byte *)sci_calloc(font->char_size, chars_nr);
+ font->data = (byte *)calloc(font->char_size, chars_nr);
for (i = 0; i < chars_nr; i++) {
int offset = READ_LE_UINT16(resource + (i << 1) + 6);
diff --git a/engines/sci/gfx/res_pal.cpp b/engines/sci/gfx/res_pal.cpp
index ff76d3e20c..dbb6f8c221 100644
--- a/engines/sci/gfx/res_pal.cpp
+++ b/engines/sci/gfx/res_pal.cpp
@@ -26,7 +26,6 @@
/* SCI1 palette resource defrobnicator */
#include "common/file.h"
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp
index 8c71bb2f49..5cf2b8ec6d 100644
--- a/engines/sci/gfx/res_pic.cpp
+++ b/engines/sci/gfx/res_pic.cpp
@@ -24,7 +24,6 @@
*/
#include <time.h> // for time() to seed rand() via srand()
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
@@ -148,7 +147,7 @@ void gfxr_init_static_palette() {
gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) {
- gfxr_pic_t *pic = (gfxr_pic_t*)sci_malloc(sizeof(gfxr_pic_t));
+ gfxr_pic_t *pic = (gfxr_pic_t*)malloc(sizeof(gfxr_pic_t));
pic->mode = mode;
@@ -1569,7 +1568,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
p0printf("Explicit priority table @%d\n", pos);
if (!pic->priorityTable) {
- pic->priorityTable = (int*)sci_malloc(16 * sizeof(int));
+ pic->priorityTable = (int*)malloc(16 * sizeof(int));
} else {
// This occurs in the title screen of Longbow, perhaps with the animated Robin sprite
GFXWARN("pic->priorityTable is not NULL (%p); this only occurs with overlaid pics, otherwise it's a bug", (void *)pic->priorityTable);
@@ -1592,7 +1591,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
int *pri_table;
if (!pic->priorityTable) {
- pic->priorityTable = (int*)sci_malloc(16 * sizeof(int));
+ pic->priorityTable = (int*)malloc(16 * sizeof(int));
} else {
GFXERROR("pic->priorityTable is not NULL (%p); possible memory corruption", (void *)pic->priorityTable);
}
diff --git a/engines/sci/gfx/res_view0.cpp b/engines/sci/gfx/res_view0.cpp
index dd01ae4ad0..efc5cccc95 100644
--- a/engines/sci/gfx/res_view0.cpp
+++ b/engines/sci/gfx/res_view0.cpp
@@ -25,7 +25,6 @@
#include "common/endian.h"
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
@@ -132,7 +131,7 @@ static int gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource,
return 1;
}
- dest->cels = (gfx_pixmap_t**)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr);
+ dest->cels = (gfx_pixmap_t**)malloc(sizeof(gfx_pixmap_t *) * cels_nr);
for (i = 0; i < cels_nr; i++) {
int cel_offset = READ_LE_UINT16(resource + offset + 4 + (i << 1));
@@ -174,7 +173,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) {
return NULL;
}
- view = (gfxr_view_t *)sci_malloc(sizeof(gfxr_view_t));
+ view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
view->ID = id;
view->loops_nr = resource[V0_LOOPS_NR_OFFSET];
@@ -198,7 +197,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) {
return NULL;
}
- view->loops = (gfxr_loop_t*)sci_malloc(sizeof(gfxr_loop_t) * ((view->loops_nr) ? view->loops_nr : 1)); /* Alloc 1 if no loop */
+ view->loops = (gfxr_loop_t*)malloc(sizeof(gfxr_loop_t) * ((view->loops_nr) ? view->loops_nr : 1)); /* Alloc 1 if no loop */
for (i = 0; i < view->loops_nr; i++) {
int error_token = 0;
diff --git a/engines/sci/gfx/res_view1.cpp b/engines/sci/gfx/res_view1.cpp
index eea8aa3259..2b0c7439a1 100644
--- a/engines/sci/gfx/res_view1.cpp
+++ b/engines/sci/gfx/res_view1.cpp
@@ -27,7 +27,6 @@
#include "common/endian.h"
-#include "sci/sci_memory.h"
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
@@ -249,7 +248,7 @@ static int gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, by
return 1;
}
- dest->cels = (gfx_pixmap_t**)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr);
+ dest->cels = (gfx_pixmap_t**)malloc(sizeof(gfx_pixmap_t *) * cels_nr);
for (i = 0; i < cels_nr; i++) {
int cel_offset = READ_LE_UINT16(resource + offset + 4 + (i << 1));
@@ -286,7 +285,7 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_p
return NULL;
}
- view = (gfxr_view_t*)sci_malloc(sizeof(gfxr_view_t));
+ view = (gfxr_view_t*)malloc(sizeof(gfxr_view_t));
view->ID = id;
view->flags = 0;
@@ -320,7 +319,7 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_p
view->palette = NULL;
}
- view->loops = (gfxr_loop_t*)sci_malloc(sizeof(gfxr_loop_t) * view->loops_nr);
+ view->loops = (gfxr_loop_t*)malloc(sizeof(gfxr_loop_t) * view->loops_nr);
for (i = 0; i < view->loops_nr; i++) {
int error_token = 0;
@@ -348,7 +347,7 @@ gfxr_loop_t *gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_bas
int i;
result->cels_nr = cels_nr;
- result->cels = (gfx_pixmap_t **)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr);
+ result->cels = (gfx_pixmap_t **)malloc(sizeof(gfx_pixmap_t *) * cels_nr);
for (i = 0; i < cels_nr; i++) {
result->cels[i] = gfxr_draw_cel1(id, loop, i, mirrored, resource_base, seeker, size, view, 0, true);
@@ -368,7 +367,7 @@ gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size) {
int i;
byte *seeker;
- view = (gfxr_view_t *)sci_malloc(sizeof(gfxr_view_t));
+ view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
memset(view, 0, sizeof(gfxr_view_t));
view->ID = id;
diff --git a/engines/sci/module.mk b/engines/sci/module.mk
index cff633dbf3..5e690fa74f 100644
--- a/engines/sci/module.mk
+++ b/engines/sci/module.mk
@@ -5,7 +5,6 @@ MODULE_OBJS = \
detection.o \
exereader.o \
sci.o \
- sci_memory.o \
tools.o \
engine/game.o \
engine/gc.o \
diff --git a/engines/sci/sci_memory.cpp b/engines/sci/sci_memory.cpp
deleted file mode 100644
index c7bd78c16e..0000000000
--- a/engines/sci/sci_memory.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/util.h"
-#include "sci/tools.h"
-#include "sci/sci_memory.h"
-
-namespace Sci {
-
-/********** the memory allocation macros **********/
-
-#ifdef UNCHECKED_MALLOCS
-
-#define ALLOC_MEM(alloc_statement, size, filename, linenum, funcname)\
-do {\
- alloc_statement;\
-} while (0);
-
-#else /* !UNCHECKED_MALLOCS */
-
-#define ALLOC_MEM(alloc_statement, size, filename, linenum, funcname)\
-do {\
- if (size == 0) {\
- warning("Allocating zero bytes of memory [%s (%s) : %u]", filename, funcname, linenum);\
- } else if (!(size > 0)) {\
- error("Cannot allocate negative bytes of memory [%s (%s) : %u]", filename, funcname, linenum);\
- }\
-\
- alloc_statement; /* attempt to allocate the memory */\
-\
- if (res == NULL) {\
- /* exit immediately */\
- error("Memory allocation of %u bytes failed [%s (%s) : %u]", (uint)(size), filename, funcname, linenum);\
- }\
-} while (0);
-
-#endif /* !UNCHECKED_MALLOCS */
-
-
-void * sci_malloc(size_t size) {
- void *res;
-
- ALLOC_MEM((res = malloc(size)), size, __FILE__, __LINE__, "")
- return res;
-}
-
-
-void * sci_calloc(size_t num, size_t size) {
- void *res;
-
- ALLOC_MEM((res = calloc(num, size)), num * size, __FILE__, __LINE__, "")
- return res;
-}
-
-void *sci_realloc(void *ptr, size_t size) {
- void *res;
-
- ALLOC_MEM((res = realloc(ptr, size)), size, __FILE__, __LINE__, "")
- return res;
-}
-
-char *sci_strdup(const char *src) {
- void *res;
-
- if (!src) {
- fprintf(stderr, "_SCI_STRDUP() [%s (%s) : %u]\n",
- __FILE__, "", __LINE__);
- fprintf(stderr, " attempt to strdup NULL pointer\n");
- BREAKPOINT();
- }
- ALLOC_MEM((res = strdup(src)), strlen(src), __FILE__, __LINE__, "")
-
- return (char*)res;
-}
-
-} // End of namespace Sci
diff --git a/engines/sci/sci_memory.h b/engines/sci/sci_memory.h
deleted file mode 100644
index 8aec598876..0000000000
--- a/engines/sci/sci_memory.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-
-// This header file defines a portable library for allocating memory safely.
-
-
-#ifndef SCI_SCI_MEMORY_H
-#define SCI_SCI_MEMORY_H
-
-#include "common/scummsys.h"
-
-namespace Sci {
-
-/********** memory allocation routines **********/
-
-extern void *sci_malloc(size_t size);
-/* Allocates the specified amount of memory.
-** Parameters: (size_t) size: Number of bytes to allocate
-** Returns : (void *) A pointer to the allocated memory chunk
-** To free this string, use the free() command.
-** If the call fails, behaviour is dependent on the definition of SCI_ALLOC.
-*/
-
-extern void *sci_calloc(size_t num, size_t size);
-/* Allocates num * size bytes of zeroed-out memory.
-** Parameters: (size_t) num: Number of elements to allocate
-** (size_t) size: Amount of memory per element to allocate
-** Returns : (void *) A pointer to the allocated memory chunk
-** To free this string, use the free() command.
-** See _SCI_MALLOC() for more information if call fails.
-*/
-
-extern void *sci_realloc(void *ptr, size_t size);
-/* Increases the size of an allocated memory chunk.
-** Parameters: (void *) ptr: The original pointer
-** (size_t) size: New size of the memory chunk
-** Returns : (void *) A possibly new pointer, containing 'size'
-** bytes of memory and everything contained in the original 'ptr'
-** (possibly minus some trailing data if the new memory area is
-** smaller than the old one).
-** To free this string, use the free() command.
-** See _SCI_MALLOC() for more information if call fails.
-*/
-
-
-extern char *sci_strdup(const char *src);
-/* Duplicates a string.
-** Parameters: (const char *) src: The original pointer
-** Returns : (char *) a pointer to the storage location for the copied
-** string.
-** To free this string, use the free() command.
-** See _SCI_MALLOC() for more information if call fails.
-*/
-
-} // End of namespace Sci
-
-#endif // SCI_SCI_MEMORY_H
diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp
index 488ed2e33b..192632a55b 100644
--- a/engines/sci/scicore/resource.cpp
+++ b/engines/sci/scicore/resource.cpp
@@ -31,7 +31,6 @@
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/tools.h"
-#include "sci/sci_memory.h"
#include "sci/scicore/resource.h"
#include "sci/scicore/vocabulary.h"
#include "sci/scicore/decompressor.h"
diff --git a/engines/sci/scicore/sciconsole.cpp b/engines/sci/scicore/sciconsole.cpp
index 863bf990b1..7f56eef7b8 100644
--- a/engines/sci/scicore/sciconsole.cpp
+++ b/engines/sci/scicore/sciconsole.cpp
@@ -26,7 +26,6 @@
/* First part of the console implmentation: VM independent stuff */
/* Remember, it doesn't have to be fast. */
-#include "sci/sci_memory.h"
#include "sci/engine/state.h"
#include "sci/scicore/sciconsole.h"
@@ -53,7 +52,7 @@ int sciprintf(const char *fmt, ...) {
va_end(argp);
// Allocate buffer for the full printed string
- char *buf = (char *)sci_malloc(bufsize + 1);
+ char *buf = (char *)malloc(bufsize + 1);
assert(buf);
// Print everything according to fmt into buf
diff --git a/engines/sci/scicore/vocab_debug.cpp b/engines/sci/scicore/vocab_debug.cpp
index 058c81c337..d626983058 100644
--- a/engines/sci/scicore/vocab_debug.cpp
+++ b/engines/sci/scicore/vocab_debug.cpp
@@ -289,7 +289,7 @@ int *vocabulary_get_classes(ResourceManager *resmgr, int* count) {
if ((r = resmgr->findResource(kResourceTypeVocab, 996, 0)) == NULL)
return 0;
- c = (int *)sci_malloc(sizeof(int) * r->size / 2);
+ c = (int *)malloc(sizeof(int) * r->size / 2);
for (i = 2; i < r->size; i += 4) {
c[i/4] = READ_LE_UINT16(r->data + i);
}
@@ -356,13 +356,13 @@ opcode* vocabulary_get_opcodes(ResourceManager *resmgr) {
count = READ_LE_UINT16(r->data);
- o = (opcode*)sci_malloc(sizeof(opcode) * 256);
+ o = (opcode*)malloc(sizeof(opcode) * 256);
for (i = 0; i < count; i++) {
int offset = READ_LE_UINT16(r->data + 2 + i * 2);
int len = READ_LE_UINT16(r->data + offset) - 2;
o[i].type = READ_LE_UINT16(r->data + offset + 2);
o[i].number = i;
- o[i].name = (char *)sci_malloc(len + 1);
+ o[i].name = (char *)malloc(len + 1);
memcpy(o[i].name, r->data + offset + 4, len);
o[i].name[len] = '\0';
#ifdef VOCABULARY_DEBUG
@@ -372,7 +372,7 @@ opcode* vocabulary_get_opcodes(ResourceManager *resmgr) {
for (i = count; i < 256; i++) {
o[i].type = 0;
o[i].number = i;
- o[i].name = (char *)sci_malloc(strlen("undefined") + 1);
+ o[i].name = (char *)malloc(strlen("undefined") + 1);
strcpy(o[i].name, "undefined");
}
return o;
diff --git a/engines/sci/scicore/vocabulary.cpp b/engines/sci/scicore/vocabulary.cpp
index 3a55e95e5c..af63a9803a 100644
--- a/engines/sci/scicore/vocabulary.cpp
+++ b/engines/sci/scicore/vocabulary.cpp
@@ -458,7 +458,7 @@ bool vocab_tokenize_string(ResultWordList &retval, const char *sentence, const W
// Look it up
if (lookup_result._class == -1) { // Not found?
- *error = (char *)sci_calloc(wordlen + 1, 1);
+ *error = (char *)calloc(wordlen + 1, 1);
strncpy(*error, lastword, wordlen); // Set the offending word
retval.clear();
return false; // And return with error
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp
index 3df36258ff..bb1bfad15a 100644
--- a/engines/sci/sfx/iterator.cpp
+++ b/engines/sci/sfx/iterator.cpp
@@ -30,7 +30,6 @@
#include "sci/sfx/iterator_internal.h"
#include "sci/sfx/player.h"
#include "sci/tools.h"
-#include "sci/sci_memory.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
diff --git a/engines/sci/sfx/seq/instrument-map.cpp b/engines/sci/sfx/seq/instrument-map.cpp
index f643a5b7be..14ce623f3e 100644
--- a/engines/sci/sfx/seq/instrument-map.cpp
+++ b/engines/sci/sfx/seq/instrument-map.cpp
@@ -25,14 +25,13 @@
#include "common/scummsys.h"
#include "sci/sfx/sci_midi.h"
-#include "sci/sci_memory.h"
#include "sci/sfx/seq/instrument-map.h"
#include "sci/sfx/core.h"
namespace Sci {
sfx_instrument_map_t *sfx_instrument_map_new(int velocity_maps_nr) {
- sfx_instrument_map_t *map = (sfx_instrument_map_t *)sci_malloc(sizeof(sfx_instrument_map_t));
+ sfx_instrument_map_t *map = (sfx_instrument_map_t *)malloc(sizeof(sfx_instrument_map_t));
int i;
map->initialisation_block_size = 0;
@@ -45,9 +44,9 @@ sfx_instrument_map_t *sfx_instrument_map_new(int velocity_maps_nr) {
map->velocity_map = NULL; /* Yes, this complicates control flow needlessly, but it avoids some of the pointless
** warnings that certain memory tools seem to find appropriate. */
else {
- map->velocity_map = (byte **)sci_malloc(sizeof(byte *) * velocity_maps_nr);
+ map->velocity_map = (byte **)malloc(sizeof(byte *) * velocity_maps_nr);
for (i = 0; i < velocity_maps_nr; ++i)
- map->velocity_map[i] = (byte *)sci_malloc(SFX_VELOCITIES_NR);
+ map->velocity_map[i] = (byte *)malloc(SFX_VELOCITIES_NR);
}
for (i = 0; i < SFX_INSTRUMENTS_NR; ++i)
map->velocity_map_index[i] = SFX_NO_VELOCITY_MAP;
@@ -170,7 +169,7 @@ sfx_instrument_map_t *sfx_instrument_map_load_sci(byte *data, size_t size) {
fprintf(stderr, "[instrument-map] Instrument larger than required by initialisation block: %d of %d\n", (int) size, PATCH_MIN_SIZE);
if (map->initialisation_block_size != 0) {
- map->initialisation_block = (byte *)sci_malloc(map->initialisation_block_size);
+ map->initialisation_block = (byte *)malloc(map->initialisation_block_size);
memcpy(map->initialisation_block, data + PATCH_INIT_DATA, map->initialisation_block_size);
}
}
@@ -480,9 +479,9 @@ midi_writer_t *sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *ma
if (map == NULL)
return writer;
- retval = (decorated_midi_writer_t *)sci_malloc(sizeof(decorated_midi_writer_t));
+ retval = (decorated_midi_writer_t *)malloc(sizeof(decorated_midi_writer_t));
retval->writer = writer;
- retval->name = (char *)sci_malloc(strlen(writer->name) + strlen(NAME_SUFFIX) + 1);
+ retval->name = (char *)malloc(strlen(writer->name) + strlen(NAME_SUFFIX) + 1);
strcpy(retval->name, writer->name);
strcat(retval->name, NAME_SUFFIX);
diff --git a/engines/sci/sfx/softseq/amiga.cpp b/engines/sci/sfx/softseq/amiga.cpp
index acd9fc444f..11feaebd96 100644
--- a/engines/sci/sfx/softseq/amiga.cpp
+++ b/engines/sci/sfx/softseq/amiga.cpp
@@ -24,7 +24,6 @@
*/
#include "sci/tools.h"
-#include "sci/sci_memory.h"
#include "sci/sfx/softseq.h"
#include "common/file.h"
@@ -374,7 +373,7 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
return NULL;
}
- instrument = (instrument_t *) sci_malloc(sizeof(instrument_t));
+ instrument = (instrument_t *) malloc(sizeof(instrument_t));
seg_size[0] = read_int16(header + 35) * 2;
seg_size[1] = read_int16(header + 41) * 2;
@@ -411,7 +410,7 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
sciprintf(" Segment sizes: %i %i %i\n", seg_size[0], seg_size[1], seg_size[2]);
sciprintf(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43));
#endif
- instrument->samples = (int8 *) sci_malloc(size + 1);
+ instrument->samples = (int8 *) malloc(size + 1);
if (file.read(instrument->samples, size) < (unsigned int)size) {
sciprintf("[sfx:seq:amiga] Error: failed to read instrument samples\n");
return NULL;
@@ -434,7 +433,7 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
instrument->size = seg_size[0];
instrument->loop_size = seg_size[1];
- instrument->loop = (int8*)sci_malloc(instrument->loop_size + 1);
+ instrument->loop = (int8*)malloc(instrument->loop_size + 1);
memcpy(instrument->loop, instrument->samples + loop_offset, instrument->loop_size);
instrument->samples[instrument->size] = instrument->loop[0];
diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp
index 5831457acb..9a11a60818 100644
--- a/engines/sci/sfx/songlib.cpp
+++ b/engines/sci/sfx/songlib.cpp
@@ -26,7 +26,6 @@
#include "sci/tools.h"
#include "sci/sfx/core.h"
#include "sci/sfx/iterator.h"
-#include "sci/sci_memory.h"
namespace Sci {
@@ -34,7 +33,7 @@ namespace Sci {
song_t *song_new(song_handle_t handle, SongIterator *it, int priority) {
song_t *retval;
- retval = (song_t*) sci_malloc(sizeof(song_t));
+ retval = (song_t*) malloc(sizeof(song_t));
#ifdef SATISFY_PURIFY
memset(retval, 0, sizeof(song_t));