|
@@ -117,6 +117,13 @@ end;
|
|
|
Internal functions, not in interface.
|
|
|
****************************************************************************}
|
|
|
|
|
|
+
|
|
|
+procedure WideStringError;
|
|
|
+ begin
|
|
|
+ HandleErrorFrame(204,get_frame);
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{$ifdef WideStrDebug}
|
|
|
Procedure DumpWideRec(S : Pointer);
|
|
|
begin
|
|
@@ -143,14 +150,20 @@ Function NewWideString(Len : SizeInt) : Pointer;
|
|
|
Var
|
|
|
P : Pointer;
|
|
|
begin
|
|
|
+{$ifdef MSWINDOWS}
|
|
|
+ P:=SysAllocStringLen(nil,Len*sizeof(WideChar)+WideRecLen);
|
|
|
+{$else MSWINDOWS}
|
|
|
GetMem(P,Len*sizeof(WideChar)+WideRecLen);
|
|
|
+{$endif MSWINDOWS}
|
|
|
If P<>Nil then
|
|
|
- begin
|
|
|
+ begin
|
|
|
PWideRec(P)^.Len:=0; { Initial length }
|
|
|
PWideRec(P)^.Ref:=1; { Set reference count }
|
|
|
PWideRec(P)^.First:=#0; { Terminating #0 }
|
|
|
inc(p,WideFirstOff); { Points to string now }
|
|
|
- end;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ WideStringError;
|
|
|
NewWideString:=P;
|
|
|
end;
|
|
|
|
|
@@ -163,7 +176,11 @@ begin
|
|
|
If S=Nil then
|
|
|
exit;
|
|
|
Dec (S,WideFirstOff);
|
|
|
+{$ifdef MSWINDOWS}
|
|
|
+ SysFreeString(S);
|
|
|
+{$else MSWINDOWS}
|
|
|
FreeMem (S);
|
|
|
+{$endif MSWINDOWS}
|
|
|
S:=Nil;
|
|
|
end;
|
|
|
|
|
@@ -607,13 +624,18 @@ begin
|
|
|
{ Need a complete new string...}
|
|
|
Pointer(s):=NewWideString(l);
|
|
|
end
|
|
|
+ { windows doesn't support reallocing widestrings, this code
|
|
|
+ is anyways subject to be removed because widestrings shouldn't be
|
|
|
+ ref. counted anymore (FK) }
|
|
|
+{$ifndef MSWINDOWS}
|
|
|
else if (PWideRec(Pointer(S)-WideFirstOff)^.Ref = 1) then
|
|
|
begin
|
|
|
Dec(Pointer(S),WideFirstOff);
|
|
|
if L*sizeof(WideChar)+WideRecLen>MemSize(Pointer(S)) then
|
|
|
- reallocmem(pointer(S), L*sizeof(WideChar)+WideRecLen);
|
|
|
+ reallocmem(pointer(S), L*sizeof(WideChar)+WideRecLen);
|
|
|
Inc(Pointer(S), WideFirstOff);
|
|
|
end
|
|
|
+{$endif MSWINDOWS}
|
|
|
else
|
|
|
begin
|
|
|
{ Reallocation is needed... }
|