01-20-2009 05:49 AM
01-20-2009 07:45 AM
Hi MB,
How are you filling the IniText? Are you using Ini_ReadFromFile, Ini_ReadFromRegistry or Ini_ReadGeneric to put label/value pairs into it? Could you post the code of your function so that we can examine it and make some simulation?
Regarding your second question, a IniFile pointer can be freed by free () function, but as you can see examining the source code of Ini_Dispose, there are several additional resources that must be deallocated and freed before the struct can be discarded. Source code of the function is available in toolbox directory the same as IniFile.fp instrument.
01-20-2009 08:24 AM
01-20-2009 10:29 AM - edited 01-20-2009 10:30 AM
Well, I see no evident reason for the error: where exactly are you finding it? Does it arises always in the same line or its position is varying?
It is necessary that your TestType stores pointers to strings? Could you try to modify it in order to have fixed lenght strings instead? This will reduce dynamic memory allocation and possibly eliminate this error.
As a side note, you can use GetGeneralErrorString ( ) to decode both User Interface Library and Toolbox errors.
01-21-2009 02:40 AM
Hey Roberto,
I don´t understand why, but I solved the problem. I just changed the sectionNamePtr to string constants, and it works. I can´t figure out, what I do wrong with this pointer to get dynamic memory corrupted:
NrOfItems = Ini_NumberOfItems(tpFile, "HEADER"); // Get HEADER Items
for(i=0; i<NrOfItems; i++){
Ini_NthItemName(tpFile, "HEADER", i+1, &tagName);
Ini_GetPointerToString(tpFile, "HEADER", tagName, &tagStrVal);
if(!(strcmp(tagName,"Type"))) SetCtrlVal(fp, FP_STRING_TYPE, tagStrVal);
...etc...
}
Yes, I want to use TestType as it is. Is it problematic to allocate memory dynamically for the srtings in the struct? Should I avoid it by declaring fixed-length strings?
Other question: If I have a filled table control, and I want to refill it with new data, do I have to use FreeTableValStrings() - of course combined with GetTableCellRangeVals()?
Thanks for the sidenote, I have already invoked it!
regards
MB
01-21-2009 04:06 AM
I suppose (but I'm not absolutely sure of it) this depends on sectionNamePtr being assigned a pointer to a local memory area in the line sectionNamePtr = "HEADER" and then passed to Ini_NumberOfItems which then manipulates the stringfor searchings and comparisons.
Regarding the table control, you can limit to pass new values to it andthey will replace previous content. FreeTableValStrings is intended to free the memori that GetTableCellRangeVals allocates if reading non-numeric values from the table.