Advertisement

need help with passing strings from function to function...

Started by January 06, 2003 09:28 PM
0 comments, last by LuckyNewbie 21 years, 10 months ago
** note: i copied the bitmap loading process from windows game programming gurus (i'm still using directdraw) ** Okay, i had these three functions designed to load a bitmap and put it in a custom class. Their declarations are as follows. int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename); int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap); // this is from a custom class, SimpleSS int SimpleSS::Init_Surface(BITMAP_FILE_PTR); Anyways, this worked fine, but then I wanted to put it into a single class function to simplify the loading process for myself. I wanted one parameter (the filename), and nothing else. This seemed like a nice idea, breaking down three different functions into a single call and error test: SimpleSS background; if (background.createSurface("background.bmp") == -1) return -1; === now heres the problem: debug assertion failed! dbgheap.c CrtIsValidHeapPointer(pUserData) Abort | Retry | Ignore etc.... and heres the code inside createSurface()

createSurface(char *filename)
{
	g_printError("Entering createSurface",debug);
	BITMAP_FILE bitmap;
	if (Load_Bitmap_File(&bitmap, filename) == -1)// load the 8-bit image
	{
		g_printError("Load_Bitmap_File failed!\n",debug);
		return -1;
	}
	else
		g_printError("Loaded Bitmap",debug);

	g_printError("Calling Init_Surface",debug);
	if ( Init_Surface(&bitmap) == -1)
	{
		g_printError("Init_Surface failed...",debug);
		return -1;
	}
	Unload_Bitmap_File(&bitmap);
	return 0;
}
   
I pinpointed the problem as starting at the first function... "Load_Bitmap_File(&bitmap, filename)", I figure that the way i'm passing in the filename to Load_Bitmap_File is just plain stupid, but strings and such are my nemesis. This seems like a pretty simple problem that I just can't figure out. Please help (and please, baby Jesus, let the code show up correct the first time...) [edited by - LuckyNewbie on January 6, 2003 12:33:19 AM]
"Let me just ejaculate some ideas"
If the prototype for Load_Bitmap_File is like you said at the start of your post ( int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename); ) then it should be fine if you call it like you did, Load_Bitmap_File(&bitmap, filename). By the way, you missed the return type (int) in your createSurface definition.

:::: Lektrix ::::
[ Google || ACCU || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on January 8, 2003 11:52:37 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement