Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, February 19, 2007 9:52:02 AM(UTC)

rbray  
rbray

Groups: Registered
Posts: 1


Hello.  I'm currently using version 13 of the Raster Imaging
API.  I have a question concerning the use of the L_FileInfo
function.  This function takes a pointer to a FILEINFO data
structure.  Does this data structure need to be zero initialized
before calling the L_FileInfo function?  What behavior can occur
if it is not zero initialized?  The documentation and many
examples suggest it doesn't require pre-initialization, however, I've
experienced random behavior in some cases when it is not zero initialized.

// sample that produces random crashes and failures
FILEINFO fileInfo;
int iRet = L_FileInfo( "test.jpg", &fileInfo, 0, NULL );


// sample that doesn't appear to produce any crashes or unexpected behavior
FILEINFO fileInfo
memset( &fileInfo, 0, sizeof( fileInfo ));
int iRet = L_FileInfo( "test.jpg", &fileInfo, 0, NULL );



Is the FILEINFO data structure used as both an input and output
argument?  Since it is easy enough to just go ahead and zero
initialize the data structure before calling L_FileInfo, I simply do
that.  I'm looking for clarification that doing so does indeed fix the random crashes we sometimes experience.

Thanks for any feedback.

Rick Bray
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, February 22, 2007 12:57:11 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)


There are 2 main uses for this structure:

1. To get file information using L_FileInfo. In this case, no need to initialize it with specific values because the function will fill it.
2. To provide information to a file loading function, such as L_LoadBitmap. If you use it this way, you must provide correct information and correct flags. For example, if you want to tell the function that you know the file type, set FileInfo.Format to the file type and set FileInfo.Flags to FILEINFO_FORMATVALID.

In any case, it's always good programming practice to fill structures with zeroes and to initialize pointers to NULL, to help you catch any hidden bugs that might creep into your code. For example, you don't the FileInfo.Flags to contain the FILEINFO_FORMATVALID value when you are not really supplying the correct format in FileInfo.Format
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.051 seconds.