Article # 562, added by Geoworks, historical record
| first | previous | index | next | last |

Using the InitFileReadStringSectionBlock routine wisely.




Q. When I use the InitFileReadStringSectionBlock routine the returned
   MemHandle is not a NullHandle.  However, the system crashes
   when I try to free the MemHandle. The size variable shows that the
   size of the string is zero.
   
   I was wondering how could I know when a new block is allocated.
   I believe that I have to free it or otherwise there will be a
   memory block that is never freed. Any ideas? Should I totally
   ignore the MemHandle and just check the size variable?

A. To know when InitFileReadStringSectionBlock did not find what you
   wanted you should check the dataSize parameter. It will be zero if
   the routine did not find the string section. However, the block
   parameter will be garbage and ECCheckMemHandle routine won't always
   catch the problem. The best thing is to check dataSize and if it's
   zero, then don't do anything with the block parameter at all. If
   dataSize is non-zero then you can use block and reference the string
   stored in it.