Added gprof support to the makefile. [Bryan Ischo]

Added a check for the OPTION_READCONFIG option before executing 
the code which would attempt to incorporate configuration file
settings into the current configuration, because if OPTION_READCONFIG 
is set to false, then there is no reason to even try to do this as 
every single configuration file will be ignored (because config files 
have been turned off by OPTION_READCONFIG). [Bryan Ischo]

Fixed small memory leak in mame.c. [Bryan Ischo]

Fixed double-free error in render.c. [Bryan Ischo]

Made core_strdup use osd_malloc instead of malloc. [Bryan Ischo]
This commit is contained in:
Aaron Giles 2010-04-08 06:10:18 +00:00
parent 2238e2d3ea
commit 717a11337e
6 changed files with 48 additions and 18 deletions

View file

@ -177,6 +177,9 @@ endif
# uncomment next line to include the internal profiler
# PROFILER = 1
# uncomment next line to include gprof profiler support
# GPROF = 1
# uncomment the force the universal DRC to always use the C backend
# you may need to do this if your target architecture does not have
# a native backend
@ -247,6 +250,12 @@ PROFILER = 1
endif
endif
# allow gprof profiling as well, which overrides the internal PROFILER
ifdef GPROF
CCOMFLAGS += -pg
PROFILER =
# LIBS += -lc_p
endif
#-------------------------------------------------
@ -284,6 +293,7 @@ RM = @rm -f
PREFIXSDL =
SUFFIX64 =
SUFFIXDEBUG =
SUFFIXGPROF =
# Windows SDL builds get an SDL prefix
ifeq ($(OSD),sdl)
@ -302,6 +312,11 @@ ifdef DEBUG
SUFFIXDEBUG = d
endif
# gprof builds get an addition 'p' suffix
ifdef GPROF
SUFFIXGPROF = p
endif
# the name is just 'target' if no subtarget; otherwise it is
# the concatenation of the two (e.g., mametiny)
ifeq ($(TARGET),$(SUBTARGET))
@ -311,7 +326,7 @@ NAME = $(TARGET)$(SUBTARGET)
endif
# fullname is prefix+name+suffix+suffix64+suffixdebug
FULLNAME = $(PREFIX)$(PREFIXSDL)$(NAME)$(SUFFIX)$(SUFFIX64)$(SUFFIXDEBUG)
FULLNAME = $(PREFIX)$(PREFIXSDL)$(NAME)$(SUFFIX)$(SUFFIX64)$(SUFFIXDEBUG)$(SUFFIXGPROF)
# add an EXE suffix to get the final emulator name
EMULATOR = $(FULLNAME)$(EXE)

View file

@ -202,7 +202,9 @@ EMUVIDEOOBJS = \
$(EMUVIDEO)/vector.o \
$(EMUVIDEO)/voodoo.o \
$(LIBEMU): $(EMUOBJS) $(EMUSOUNDOBJS) $(EMUAUDIOOBJS) $(EMUDRIVEROBJS) $(EMUMACHINEOBJS) $(EMUVIDEOOBJS)
LIBEMUOBJS = $(EMUOBJS) $(EMUSOUNDOBJS) $(EMUAUDIOOBJS) $(EMUDRIVEROBJS) $(EMUMACHINEOBJS) $(EMUVIDEOOBJS)
$(LIBEMU): $(LIBEMUOBJS)

View file

@ -261,8 +261,11 @@ int mame_execute(core_options *options)
firstgame = FALSE;
/* parse any INI files as the first thing */
options_revert(mame_options(), OPTION_PRIORITY_INI);
mame_parse_ini_files(mame_options(), driver);
if (options_get_bool(options, OPTION_READCONFIG))
{
options_revert(mame_options(), OPTION_PRIORITY_INI);
mame_parse_ini_files(mame_options(), driver);
}
/* create the machine structure and driver */
machine = global_alloc(running_machine(driver));
@ -1327,6 +1330,8 @@ running_machine::running_machine(const game_driver *driver)
auto_free(this, driver_data);
if (config != NULL)
machine_config_free((machine_config *)config);
if (basename != NULL)
osd_free(basename);
if (mame_data != NULL)
auto_free(this, mame_data);
}
@ -1343,6 +1348,8 @@ running_machine::~running_machine()
if (config != NULL)
machine_config_free((machine_config *)config);
if (basename != NULL)
osd_free(basename);
global_machine = NULL;
}

View file

@ -236,15 +236,15 @@ public:
ioport_list portlist; /* points to a list of input port configurations */
/* CPU information */
running_device * firstcpu; /* first CPU (allows for quick iteration via typenext) */
running_device * firstcpu; /* first CPU (allows for quick iteration via typenext) */
/* game-related information */
const game_driver * gamedrv; /* points to the definition of the game machine */
const char * basename; /* basename used for game-related paths */
char * basename; /* basename used for game-related paths */
/* video-related information */
gfx_element * gfx[MAX_GFX_ELEMENTS];/* array of pointers to graphic sets (chars, sprites) */
running_device * primary_screen; /* the primary screen device, or NULL if screenless */
running_device * primary_screen; /* the primary screen device, or NULL if screenless */
palette_t * palette; /* global palette object */
/* palette-related information */

View file

@ -618,6 +618,18 @@ static void render_exit(running_machine *machine)
while (*texture_ptr != NULL && (*texture_ptr)->base != *texture_ptr)
*texture_ptr = (*texture_ptr)->next;
/* free the targets; this must be done before freeing the texture groups
as that will forcefully free everything, and if it goes first, we may
end up double-freeing textures of the render targets */
while (targetlist != NULL)
render_target_free(targetlist);
/* free the screen overlay; similarly, do this before any of the following
calls to avoid double-frees */
if (screen_overlay != NULL)
bitmap_free(screen_overlay);
screen_overlay = NULL;
/* free the texture groups */
while (render_texture_free_list != NULL)
{
@ -649,15 +661,6 @@ static void render_exit(running_machine *machine)
container_item_free_list = temp->next;
global_free(temp);
}
/* free the targets */
while (targetlist != NULL)
render_target_free(targetlist);
/* free the screen overlay */
if (screen_overlay != NULL)
bitmap_free(screen_overlay);
screen_overlay = NULL;
}
@ -1557,6 +1560,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
root_xform.yscale = (float) visheight;
root_xform.color.r = root_xform.color.g = root_xform.color.b = root_xform.color.a = 1.0f;
root_xform.orientation = target->orientation;
root_xform.no_center = FALSE;
/* iterate over layers back-to-front, but only if we're running */
if (mame_get_phase(target->machine) >= MAME_PHASE_RESET)
@ -1591,6 +1595,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
item_xform.color.b = item->color.b * root_xform.color.b;
item_xform.color.a = item->color.a * root_xform.color.a;
item_xform.orientation = orientation_add(item->orientation, root_xform.orientation);
item_xform.no_center = FALSE;
/* if there is no associated element, it must be a screen element */
if (item->element != NULL)
@ -1667,6 +1672,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
ui_xform.yscale = (float) target->height;
ui_xform.color.r = ui_xform.color.g = ui_xform.color.b = ui_xform.color.a = 1.0f;
ui_xform.orientation = target->orientation;
ui_xform.no_center = FALSE;
/* add UI elements */
add_container_primitives(target, &target->primlist[listnum], &ui_xform, ui_container, BLENDMODE_ALPHA);

View file

@ -133,7 +133,7 @@ int core_strwildcmp(const char *sp1, const char *sp2)
/*-------------------------------------------------
core_strdup - string duplication via malloc
core_strdup - string duplication via osd_malloc
-------------------------------------------------*/
char *core_strdup(const char *str)
@ -141,7 +141,7 @@ char *core_strdup(const char *str)
char *cpy = NULL;
if (str != NULL)
{
cpy = (char *)malloc(strlen(str) + 1);
cpy = (char *)osd_malloc(strlen(str) + 1);
if (cpy != NULL)
strcpy(cpy, str);
}