Subject | How do i make my UDF Thread/Multiuser Safe ? |
---|---|
Author | Kamlesh |
Post date | 2007-03-09T12:57Z |
Dear Friends
can allocating new memory and freeing it with FREE_IT make my udf
thread/multiuser safe or i'll have to use Critical Section ?
can following function be said thread safe ?
Function TrimProper(AStr:PChar):PChar;
Var
I,L: Integer;
begin
L := StrLen(AStr);
Result := StrAlloc(L);
I := 0;
While (I <= L) and (AStr[I] <= ' ') Do Inc(I);
if I < L Then
begin
while AStr[L] <= ' ' do Dec(L);
Result := StrLCopy(Result,@AStr[I],L-I+1);
Result[L+1] := #0;
Result := SysUtils.StrLower(Result);
Result[0]:=UpCase(Result[0]);
For i:=1 to StrLen(Result)-1 Do
If Result[i]=' ' Then Result[i+1]:=UpCase(Result[i+1]);
end;
End;
===================================================
how do i make non-string functions thread safe ?
is there any examples/link for detailed explanation ?
Thanks
Kamlesh
can allocating new memory and freeing it with FREE_IT make my udf
thread/multiuser safe or i'll have to use Critical Section ?
can following function be said thread safe ?
Function TrimProper(AStr:PChar):PChar;
Var
I,L: Integer;
begin
L := StrLen(AStr);
Result := StrAlloc(L);
I := 0;
While (I <= L) and (AStr[I] <= ' ') Do Inc(I);
if I < L Then
begin
while AStr[L] <= ' ' do Dec(L);
Result := StrLCopy(Result,@AStr[I],L-I+1);
Result[L+1] := #0;
Result := SysUtils.StrLower(Result);
Result[0]:=UpCase(Result[0]);
For i:=1 to StrLen(Result)-1 Do
If Result[i]=' ' Then Result[i+1]:=UpCase(Result[i+1]);
end;
End;
===================================================
how do i make non-string functions thread safe ?
is there any examples/link for detailed explanation ?
Thanks
Kamlesh