BUG: Delphi RTL70 - Compiling OWL apps within Delphi

I'm currently trying to make a 50K lines BP 7.0 OWL app run under Delphi, and
am getting a lot of interresting new errors.

There is a couple of potential problems in the RTL70 source regarding the use
of PChars.  

First, the Strings unit is still used by the RTL 7.0 units.

Secondly, the StrNew/StrDispose of the Strings unit is not compatible with
those of the SysUtils unit.

Also, for pChars, you cannot do a GetMem, and then a StrDispose when using the
SysUtils unit.  

The reason is that Borland has rewritten the StrNew/StrDispose functions and
added some "magic" to them.  When you do a StrNew(string), the actual
allocation is: GetMem(pChar, 2 + StrLen(string) + terminating nul).
(See lines 2750..2782 of SOURCE/RTL/SYS/SYSUTILS.PAS)

The leading word is used to store the size of the allocation in bytes.
The pChar returned by StrNew actually points to the third byte of the
allocation.  

When StrDispose is called, it decrements the pChar two places to get the
actual size of the allocation and does a freemem(pChar, Word(Pointer(pChar)^).

Hence, if you used the Strings unit's StrNew and the SysUtils StrDispose, or
vice versa, you'll get an RTE 204 Invalid Pointer Operation.

To put it short: Mixing Strings and SysUtils is hazardous to your app.

To try to fix this, I decided to avoid Strings and made a backup of the RTL70
units and changed them to use the SysUtils unit instead of Strings.
This alerted me of a new problem: The TStream.StrRead function used a GetMem
instead of a StrNew, and hence the eventual StrDispose crashed.

To fix it, I pathced the Objects source at line 733
{    StrRead := P;}
{*} StrRead:=StrNew(P);
{*} FreeMem(P, L + 1);

I also checked the other RTL70 units for StrNew/GetMem/StrDispose, but found
only one other potential problem.  In oDialogs TEdit.Transfer at line 1795
there is a reallocation when certain conditions are present.
It seems that the disposal at line 1801 may cause a RTE 204 if the SetData
text is > 255 chars.  

I'd like someone else to verify the problem before I call it a bug.

I'm still trying to sort out another incompatability regarding MDI child
windows that have an internal child window themselves.
I keep getting Application Error -4 (Invalid Child)...
Hopefully, it's something I did and not a bug.

All the best,
Lars F.
--
/ Mr.Lars Fosdal    / Falcon AS   (a REUTERS company) / Tel.+47 22831310
/ lfos...@falcon.no / Stranden 1, N-0250 OSLO, Norway / Fax.+47 22831290