1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0011758: TCollection strings are not memory safe as reported by Purify

Custom string handling code enabled by OptJr macro removed from implementation of strings in TCollection and elsewhere.
Functions from string.h are used instead of macros from Standard_String.hxx
File Standard_String.hxx and methods ISSIMILAR and HASHCODE of TCollection*String classes are removed (to be replaced by strcasecmp).
Functions HashCode for strings reimplemented using DJB2 algorithm for C strings and SDBM algorithm for extended strings.
Adding test cases and draw-command for issue CR11758
Fix misprint added with previous integration
Fix misprint in the test command.
Remove compilation warnings (Linux).
Avoid compiler warning "dereferencing type-punned pointer will break strict-aliasing rules" on Linux
This commit is contained in:
vsr
2013-08-22 11:21:09 +04:00
committed by bugmaster
parent 80cd454f1d
commit 29cb310ae9
18 changed files with 744 additions and 2414 deletions

View File

@@ -99,13 +99,6 @@
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <Standard_Macro.hxx>
#ifdef OptJr
#define ROUNDMEM(len) (((len)+3)&~0x3)
#else
#define ROUNDMEM(len) (len)
#endif
//=======================================================================
//function : DDataStd_SetInteger
//purpose : SetInteger (DF, entry, value)
@@ -1128,7 +1121,7 @@ static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di,
unsigned char prefix[4] = {0xEF,0xBB,0xBF, 0x00};
anOS.write( (char*)&prefix[0], 3);
Standard_Integer n = aES.LengthOfCString();
Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(ROUNDMEM(n+1));
Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(n+1);
n = aES.ToUTF8CString(aCstr);
anOS.write( (char*)&aCstr[0], n);
anOS.close();