[AD] [ alleg-Bugs-1911984 ] pack_fwrite stop working after saving more than 10.000 elems

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Bugs item #1911984, was opened at 2008-03-11 16:59
Message generated for change (Comment added) made by l_devil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=1911984&group_id=5665

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: L_Dev (l_devil)
Assigned to: Nobody/Anonymous (nobody)
Summary: pack_fwrite stop working after saving more than 10.000 elems

Initial Comment:
DESCRIPTION:

Allegro version 4.2.2.0 precompiled for MSVC 2005 grabbed from allegro.cc gave unexpected behavior during save of vast amount of small portion of data by "pack_write".

HOW TO REPRODUCE:

Following code reproduces the error. It was tested on x86 machine with Windows XP SP2. It was compiled on free Microsoft Visual C++ Express 2005

############################ - CODE BEGINS HERE

#define _CRT_SECURE_NO_WARNINGS // for MSVC 2005 and newer

#include <allegro.h>
#if defined WIN32 || defined _WINDOWS
#include <winalleg.h>
#endif
#include <cstdlib>

#if defined WIN32 || defined _WINDOWS
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, char * Cmd, int nShow)
#else
int main(int argc, char ** argv)
#endif
{
	if(allegro_init()!=0)
		return 1;

	packfile_password(NULL);
	PACKFILE * pack = pack_fopen("./test.txt", F_WRITE);
	for(int i=0; i<5000; i++)
	{
		char temp[25];
		_itoa(i, temp, 10);
		if(pack_fwrite(temp, strlen(temp), pack)!=strlen(temp))
		{
			allegro_message(allegro_error);
			return 1;
		}
		strcpy(temp, ".) ");
		if(pack_fwrite(temp, strlen(temp), pack)!=strlen(temp))
		{
			allegro_message(allegro_error);
			return 1;
		}
		if(pack_fwrite(&i, sizeof(i), pack)!=sizeof(i))
		{
			allegro_message(allegro_error);
			return 1;
		}
		if(pack_fwrite("\r\n", strlen("\r\n"), pack)!=strlen("\r\n"))
		{
			allegro_message(allegro_error);
			return 1;
		}
	}
	allegro_message("Operation Successful");
	allegro_exit();
	return 0;
}

############################ - CODE ENDS HERE.

Result? Allegro gave "Operation Successful" message, but file "./test.txt" ends on 4810 entry (and that entry is incomplete) and is missing next 190 entries!
To notice: all functions reports nothing off the ordinary, Allegro says that everything goes correctly.

----------------------------------------------------------------------

>Comment By: L_Dev (l_devil)
Date: 2008-03-11 17:10

Message:
Logged In: YES 
user_id=1362424
Originator: YES

Sorry, it seems that Sourceforge.net ate tabs. I hope this will be no
problem :-)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=1911984&group_id=5665




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/