diff options
author | Torbjörn Andersson | 2005-01-02 14:52:11 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-01-02 14:52:11 +0000 |
commit | 5f6108052e24fbf4a309ae5c315278b992d76ede (patch) | |
tree | d25d5d688dfe3f767f9ffb40469153662444278c /saga | |
parent | 1bc636aaa676839c6e8fe2d8cc1405f2c3b2393c (diff) | |
download | scummvm-rg350-5f6108052e24fbf4a309ae5c315278b992d76ede.tar.gz scummvm-rg350-5f6108052e24fbf4a309ae5c315278b992d76ede.tar.bz2 scummvm-rg350-5f6108052e24fbf4a309ae5c315278b992d76ede.zip |
Changed "sizeof x" to "sizeof(x)" for consistency with the rest of ScummVM,
and used ARRAYSIZE() instead in two cases.
svn-id: r16408
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actionmap.cpp | 2 | ||||
-rw-r--r-- | saga/actor.cpp | 2 | ||||
-rw-r--r-- | saga/animation.cpp | 4 | ||||
-rw-r--r-- | saga/events.cpp | 4 | ||||
-rw-r--r-- | saga/font.cpp | 10 | ||||
-rw-r--r-- | saga/game.cpp | 2 | ||||
-rw-r--r-- | saga/isomap.cpp | 4 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 4 | ||||
-rw-r--r-- | saga/objectmap.cpp | 14 | ||||
-rw-r--r-- | saga/rscfile.cpp | 4 | ||||
-rw-r--r-- | saga/scene.cpp | 6 | ||||
-rw-r--r-- | saga/script.cpp | 12 | ||||
-rw-r--r-- | saga/sprite.cpp | 6 | ||||
-rw-r--r-- | saga/sthread.cpp | 2 |
14 files changed, 38 insertions, 38 deletions
diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index 6494bcf031..ddc7aa4633 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -50,7 +50,7 @@ void ActionMap::load(const byte *resourcePointer, size_t resourceLength) { if (_stepZoneList) error("ActionMap::load _stepZoneList != NULL"); - _stepZoneList = (HitZone **) malloc(_stepZoneListCount * sizeof (HitZone *)); + _stepZoneList = (HitZone **) malloc(_stepZoneListCount * sizeof(HitZone *)); if (_stepZoneList == NULL) { error("ActionMap::load Memory allocation failure"); } diff --git a/saga/actor.cpp b/saga/actor.cpp index 6d6c781653..6caa325189 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -124,7 +124,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { _xCellCount = _vm->getDisplayWidth() / 2; _pathCellCount = _yCellCount * _xCellCount; - _pathCell = (int*)malloc(_pathCellCount * sizeof *_pathCell); + _pathCell = (int*)malloc(_pathCellCount * sizeof(*_pathCell)); _pathRect.left = 0; diff --git a/saga/animation.cpp b/saga/animation.cpp index aff853b70d..900325f634 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -79,7 +79,7 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i return FAILURE; } - new_anim = (ANIMATION *)malloc(sizeof *new_anim); + new_anim = (ANIMATION *)malloc(sizeof(*new_anim)); if (new_anim == NULL) { warning("Anim::load Allocation failure"); return MEM; @@ -96,7 +96,7 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i if (_vm->_gameType == GType_ITE) { // Cache frame offsets - new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof *new_anim->frame_offsets); + new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof(*new_anim->frame_offsets)); if (new_anim->frame_offsets == NULL) { warning("Anim::load Allocation failure"); return MEM; diff --git a/saga/events.cpp b/saga/events.cpp index a9643fc98c..15374ebf08 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -106,7 +106,7 @@ int Events::handleEvents(long msec) { // and reprocess the event */ delta_time = event_p->time; EVENT *from_chain=event_p->chain; - memcpy(event_p, from_chain,sizeof *event_p); + memcpy(event_p, from_chain,sizeof(*event_p)); free(from_chain); event_p->time += delta_time; @@ -435,7 +435,7 @@ EVENT *Events::chain(EVENT *head_event, EVENT *add_event) { EVENT *new_event; // Allocate space for new event - new_event = (EVENT *)malloc(sizeof *new_event); + new_event = (EVENT *)malloc(sizeof(*new_event)); if (new_event == NULL) { return NULL; } diff --git a/saga/font.cpp b/saga/font.cpp index cc65e53757..9814540d8c 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -47,7 +47,7 @@ Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) { assert(_nFonts > 0); - _fonts = (FONT **)malloc(_nFonts * sizeof *_fonts); + _fonts = (FONT **)malloc(_nFonts * sizeof(*_fonts)); if (_fonts == NULL) { error("Font::Font(): Memory allocation failure."); } @@ -109,7 +109,7 @@ int Font::loadFont(uint32 font_rn, int font_id) { MemoryReadStreamEndian readS(fontres_p, fontres_len, IS_BIG_ENDIAN); // Create new font structure - font = (FONT *)malloc(sizeof *font); + font = (FONT *)malloc(sizeof(*font)); if (font == NULL) { error("Font:loadFont(): Memory allocation error."); return MEM; @@ -127,7 +127,7 @@ int Font::loadFont(uint32 font_rn, int font_id) { debug(2, "Row padding: %d", fh.row_length); // Create normal font style - normal_font = (FONT_STYLE *)malloc(sizeof *normal_font); + normal_font = (FONT_STYLE *)malloc(sizeof(*normal_font)); if (normal_font == NULL) { error("Font::loadFont(): Memory allocation error."); free(font); @@ -215,14 +215,14 @@ FONT_STYLE *Font::createOutline(FONT_STYLE *src_font) { unsigned char c_rep; // Create new font style structure - new_font = (FONT_STYLE *)malloc(sizeof *new_font); + new_font = (FONT_STYLE *)malloc(sizeof(*new_font)); if (new_font == NULL) { error("Font::createOutline(): Memory allocation error."); return NULL; } - memset(new_font, 0, sizeof *new_font); + memset(new_font, 0, sizeof(*new_font)); // Populate new font style character data for (i = 0; i < FONT_CHARCOUNT; i++) { diff --git a/saga/game.cpp b/saga/game.cpp index 3de12efb5d..b0ad3b2536 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -759,7 +759,7 @@ int SagaEngine::loadGame(int game_n) { game_filect = GameDescs[game_n].gd_filect; - GameModule.gfile_data = (GAME_FILEDATA *)malloc(game_filect * sizeof *GameModule.gfile_data); + GameModule.gfile_data = (GAME_FILEDATA *)malloc(game_filect * sizeof(*GameModule.gfile_data)); if (GameModule.gfile_data == NULL) { return MEM; } diff --git a/saga/isomap.cpp b/saga/isomap.cpp index bec8170ac5..6d9ac7b35f 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -55,7 +55,7 @@ int IsoMap::loadTileset(const byte *tileres_p, size_t tileres_len) { readS.seek(0); - tile_tbl = (ISOTILE_ENTRY *)malloc(_tile_ct * sizeof *tile_tbl); + tile_tbl = (ISOTILE_ENTRY *)malloc(_tile_ct * sizeof(*tile_tbl)); if (tile_tbl == NULL) { return MEM; } @@ -88,7 +88,7 @@ int IsoMap::loadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { MemoryReadStreamEndian readS(mtileres_p, mtileres_len, IS_BIG_ENDIAN); mtile_ct = mtileres_len / SAGA_METATILE_ENTRY_LEN; - mtile_tbl = (ISO_METATILE_ENTRY *)malloc(mtile_ct * sizeof *mtile_tbl); + mtile_tbl = (ISO_METATILE_ENTRY *)malloc(mtile_ct * sizeof(*mtile_tbl)); if (mtile_tbl == NULL) { return MEM; } diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index c67777035b..47f48256cf 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -654,7 +654,7 @@ int Scene::ITEIntroValleyProc(int param, SCENE_INFO *scene_info) { "Jon Van Caneghem", MEDIUM_FONT_ID} }; - int n_credits = sizeof credits / sizeof credits[0]; + int n_credits = ARRAYSIZE(credits); int event_delay = 3000; switch (param) { @@ -926,7 +926,7 @@ int Scene::ITEIntroFairePathProc(int param, SCENE_INFO *scene_info) { MEDIUM_FONT_ID} }; - int n_credits = sizeof credits / sizeof credits[0]; + int n_credits = ARRAYSIZE(credits); switch (param) { case SCENE_BEGIN: diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp index 16bceb1012..6623042dbe 100644 --- a/saga/objectmap.cpp +++ b/saga/objectmap.cpp @@ -48,7 +48,7 @@ HitZone::HitZone(MemoryReadStreamEndian *readStream) { _nameNumber = readStream->readUint16(); _scriptNumber = readStream->readUint16(); - _clickAreas = (HitZone::ClickArea *)malloc(_clickAreasCount * sizeof *_clickAreas); + _clickAreas = (HitZone::ClickArea *)malloc(_clickAreasCount * sizeof(*_clickAreas)); if (_clickAreas == NULL) { error("HitZone::HitZone Memory allocation failed"); @@ -60,7 +60,7 @@ HitZone::HitZone(MemoryReadStreamEndian *readStream) { assert(clickArea->pointsCount); - clickArea->points = (Point *)malloc(clickArea->pointsCount * sizeof *(clickArea->points)); + clickArea->points = (Point *)malloc(clickArea->pointsCount * sizeof(*(clickArea->points))); if (clickArea->points == NULL) { error("HitZone::HitZone Memory allocation failed"); } @@ -163,7 +163,7 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { // Obtain object count N and allocate space for N objects _nObjects = readS.readUint16(); - _objectMaps = (OBJECTMAP_ENTRY *)malloc(_nObjects * sizeof *_objectMaps); + _objectMaps = (OBJECTMAP_ENTRY *)malloc(_nObjects * sizeof(*_objectMaps)); if (_objectMaps == NULL) { warning("Error: Memory allocation failed"); @@ -179,7 +179,7 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { readS.readByte(); object_map->objectNum = readS.readUint16(); object_map->scriptNum = readS.readUint16(); - object_map->clickareas = (CLICKAREA *)malloc(object_map->nClickareas * sizeof *(object_map->clickareas)); + object_map->clickareas = (CLICKAREA *)malloc(object_map->nClickareas * sizeof(*(object_map->clickareas))); if (object_map->clickareas == NULL) { warning("Error: Memory allocation failed"); @@ -192,7 +192,7 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) { clickarea->n_points = readS.readUint16LE(); assert(clickarea->n_points != 0); - clickarea->points = (Point *)malloc(clickarea->n_points * sizeof *(clickarea->points)); + clickarea->points = (Point *)malloc(clickarea->n_points * sizeof(*(clickarea->points))); if (clickarea->points == NULL) { warning("Error: Memory allocation failed"); return MEM; @@ -263,7 +263,7 @@ int ObjectMap::loadNames(const unsigned char *onl_res, size_t onl_res_len) { _nNames = n_names; debug(2, "ObjectMap::loadNames: Loading %d object names.", n_names); - _names = (const char **)malloc(n_names * sizeof *_names); + _names = (const char **)malloc(n_names * sizeof(*_names)); if (_names == NULL) { warning("Error: Memory allocation failed"); @@ -369,7 +369,7 @@ int ObjectMap::draw(SURFACE *ds, const Point& imousePt, int color, int color2) { for (i = 0; i < _nObjects; i++) { draw_color = color; if (hitObject && (objectNum == _objectMaps[i].objectNum)) { - snprintf(txt_buf, sizeof txt_buf, "obj %d: v %d, f %X", + snprintf(txt_buf, sizeof(txt_buf), "obj %d: v %d, f %X", _objectMaps[i].objectNum, _objectMaps[i].defaultVerb, _objectMaps[i].flags); diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index a234a9a210..2b6c430569 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -39,7 +39,7 @@ RSCFILE_CONTEXT *RSC_CreateContext() { empty_context.rc_file = new File(); RSCFILE_CONTEXT *new_context; - new_context = (RSCFILE_CONTEXT *)malloc(sizeof *new_context); + new_context = (RSCFILE_CONTEXT *)malloc(sizeof(*new_context)); if (new_context == NULL) { return NULL; } @@ -141,7 +141,7 @@ int RSC_LoadRSC(RSCFILE_CONTEXT *rsc) { return FAILURE; } - rsc_restbl = (RSCFILE_RESOURCE *)malloc(res_tbl_ct * sizeof *rsc_restbl); + rsc_restbl = (RSCFILE_RESOURCE *)malloc(res_tbl_ct * sizeof(*rsc_restbl)); if (rsc_restbl == NULL) { free(tbl_buf); return FAILURE; diff --git a/saga/scene.cpp b/saga/scene.cpp index db224eff79..68cfb0c24e 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -77,7 +77,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) { } _sceneCount = scene_lut_len / 2; _sceneMax = _sceneCount - 1; - _sceneLUT = (int *)malloc(_sceneMax * sizeof *_sceneLUT); + _sceneLUT = (int *)malloc(_sceneMax * sizeof(*_sceneLUT)); if (_sceneLUT == NULL) { warning("Scene::Scene(): Memory allocation failed"); return; @@ -708,7 +708,7 @@ int Scene::loadSceneResourceList(uint32 reslist_rn) { // Allocate memory for scene resource list _resListEntries = resource_list_len / SAGA_RESLIST_ENTRY_LEN; debug(0, "Scene resource list contains %d entries.", _resListEntries); - _resList = (SCENE_RESLIST *)calloc(_resListEntries, sizeof *_resList); + _resList = (SCENE_RESLIST *)calloc(_resListEntries, sizeof(*_resList)); if (_resList == NULL) { warning("Scene::loadSceneResourceList(): Error: Memory allocation failed"); @@ -764,7 +764,7 @@ int Scene::processSceneResources() { } pal_p = _vm->getImagePal(_bg.res_buf, _bg.res_len); - memcpy(_bg.pal, pal_p, sizeof _bg.pal); + memcpy(_bg.pal, pal_p, sizeof(_bg.pal)); _sceneMode = SCENE_MODE_NORMAL; break; case SAGA_BG_MASK: // Scene background mask resource diff --git a/saga/script.cpp b/saga/script.cpp index 76f10e4b5d..3cf41d77b0 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -266,7 +266,7 @@ int Script::loadScript(int script_num) { // Initialize script data structure debug(0, "Loading script data for script #%d", script_num); - script_data = (SCRIPTDATA *)malloc(sizeof *script_data); + script_data = (SCRIPTDATA *)malloc(sizeof(*script_data)); if (script_data == NULL) { error("Memory allocation failed"); } @@ -402,13 +402,13 @@ SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { // Allocate a new bytecode resource information structure and table of // entrypoints - bc_new_data = (SCRIPT_BYTECODE *)malloc(sizeof *bc_new_data); + bc_new_data = (SCRIPT_BYTECODE *)malloc(sizeof(*bc_new_data)); if (bc_new_data == NULL) { warning("Memory allocation failure loading script bytecode"); return NULL; } - bc_ep_tbl = (PROC_TBLENTRY *)malloc(n_entrypoints * sizeof *bc_ep_tbl); + bc_ep_tbl = (PROC_TBLENTRY *)malloc(n_entrypoints * sizeof(*bc_ep_tbl)); if (bc_ep_tbl == NULL) { warning("Memory allocation failure creating script entrypoint table"); free(bc_new_data); @@ -462,7 +462,7 @@ void Script::loadStrings(const byte *stringsPointer, size_t stringsLength, Strin debug(9, "Loading strings list..."); // Allocate dialogue list structure - strings = (StringsList *)malloc(sizeof *strings); + strings = (StringsList *)malloc(sizeof(*strings)); if (strings == NULL) { error("No enough memory for strings list"); } @@ -503,7 +503,7 @@ VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCR uint16 i; - voice_lut = (VOICE_LUT *)malloc(sizeof *voice_lut); + voice_lut = (VOICE_LUT *)malloc(sizeof(*voice_lut)); if (voice_lut == NULL) { return NULL; } @@ -514,7 +514,7 @@ VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, SCR return NULL; } - voice_lut->voices = (int *)malloc(voice_lut->n_voices * sizeof *voice_lut->voices); + voice_lut->voices = (int *)malloc(voice_lut->n_voices * sizeof(*voice_lut->voices)); if (voice_lut->voices == NULL) { return NULL; diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 92f1d24bf7..f0e61e48f6 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -83,14 +83,14 @@ int Sprite::loadList(int resource_num, SPRITELIST **sprite_list_p) { sprite_count = readS.readUint16(); - new_slist = (SPRITELIST *)malloc(sizeof *new_slist); + new_slist = (SPRITELIST *)malloc(sizeof(*new_slist)); if (new_slist == NULL) { return MEM; } new_slist->sprite_count = sprite_count; - new_slist->offset_list = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list); + new_slist->offset_list = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof(*new_slist->offset_list)); if (new_slist->offset_list == NULL) { free(new_slist); return MEM; @@ -134,7 +134,7 @@ int Sprite::appendList(int resource_num, SPRITELIST *spritelist) { old_sprite_count = spritelist->sprite_count; new_sprite_count = spritelist->sprite_count + sprite_count; - test_p = realloc(spritelist->offset_list, new_sprite_count * sizeof *spritelist->offset_list); + test_p = realloc(spritelist->offset_list, new_sprite_count * sizeof(*spritelist->offset_list)); if (test_p == NULL) { return MEM; } diff --git a/saga/sthread.cpp b/saga/sthread.cpp index e08ab2f99f..b3cd01bba0 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -666,7 +666,7 @@ int Script::SThreadRun(SCRIPT_THREAD *thread, int instr_limit) { param1 = thread->pop(); iparam2 = (long)param2; // Preserve most significant bit - data = (0x01 << ((sizeof param1 * CHAR_BIT) - 1)) & param1; + data = (0x01 << ((sizeof(param1) * CHAR_BIT) - 1)) & param1; for (i = 0; i < (int)iparam2; i++) { param1 >>= 1; param1 |= data; |