From 60829984c75c884e34bba5d3b9fe1fe31cf7f6fd Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 19 Dec 2009 12:04:23 +0000 Subject: [PATCH] Some fixes: Maximize constness, correct fromDump and remove unnecessary parameters --- game_info.cpp | 12 ++++++------ game_info.hh | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/game_info.cpp b/game_info.cpp index 930a72a..1140bb0 100644 --- a/game_info.cpp +++ b/game_info.cpp @@ -8,7 +8,7 @@ #define VERSION_BASE (0x1978) #define VERSION_MAGIC (VERSION_BASE + 0) -GameInfo::GameInfo(char *name, char *author, SDL_Surface *image) +GameInfo::GameInfo(const char *name, const char *author, SDL_Surface *image) { this->name = name; this->author = author; @@ -22,8 +22,8 @@ GameInfo::~GameInfo() void GameInfo::resetDefaults() { - free(this->name); - free(this->author); + free((void*)this->name); + free((void*)this->author); SDL_FreeSurface(this->screenshot); this->name = NULL; @@ -31,14 +31,14 @@ void GameInfo::resetDefaults() this->screenshot = NULL; } -struct game_info *GameInfo::dump(size_t *out_sz) +struct game_info *GameInfo::dump() { size_t total_sz = sizeof(struct game_info); size_t png_sz; struct game_info *out; void *png_data; - if (this->screenshot) + if (!this->screenshot) return NULL; /* Convert surface to PNG */ @@ -73,7 +73,7 @@ struct game_info *GameInfo::dump(size_t *out_sz) return out; } -void GameInfo::fromDump(struct game_info *gi, size_t sz) +void GameInfo::fromDump(struct game_info *gi) { SDL_RWops *rw; diff --git a/game_info.hh b/game_info.hh index 28e88b1..36dbe80 100644 --- a/game_info.hh +++ b/game_info.hh @@ -16,21 +16,21 @@ struct game_info class GameInfo { public: - GameInfo(char *name = NULL, char *author = NULL, SDL_Surface *image = NULL); + GameInfo(const char *name = NULL, const char *author = NULL, SDL_Surface *image = NULL); ~GameInfo(); void resetDefaults(); /** Returns an allocated dump structure */ - struct game_info *dump(size_t *out_sz); + struct game_info *dump(); /** Fill in this game info object from a structure */ - void fromDump(struct game_info *data, size_t sz); + void fromDump(struct game_info *data); protected: - char *name; - char *author; + const char *name; + const char *author; SDL_Surface *screenshot; };