summaryrefslogtreecommitdiff
path: root/plugins/Actman30/iac_global.pas
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2014-02-10 17:25:36 +0000
committerAlexey Kulakov <panda75@bk.ru>2014-02-10 17:25:36 +0000
commit34353afa23f23d9bc3470896248b8c387465a4b2 (patch)
treef9bc3857fb8e85c129962f9c126c0bd3205e7621 /plugins/Actman30/iac_global.pas
parent98255a26483a7c70fdd700ac7c41640f709d55e4 (diff)
Miranda API sync with small compilation fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@8083 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Actman30/iac_global.pas')
-rw-r--r--plugins/Actman30/iac_global.pas101
1 files changed, 72 insertions, 29 deletions
diff --git a/plugins/Actman30/iac_global.pas b/plugins/Actman30/iac_global.pas
index 1d7957a3bc..cba955d762 100644
--- a/plugins/Actman30/iac_global.pas
+++ b/plugins/Actman30/iac_global.pas
@@ -89,8 +89,8 @@ procedure InsertString(wnd:HWND;num:dword;str:PAnsiChar);
function GetLink(hash:dword):pActModule;
function GetLinkByName(name:pAnsiChar):pActModule;
-function ImportContact (node:HXML ):THANDLE;
-function ImportContactINI(node:pointer):THANDLE;
+function ImportContact (node:HXML ):HCONTACT;
+function ImportContactINI(node:pointer):HCONTACT;
implementation
@@ -301,7 +301,7 @@ const
ioCUID = 'cuid';
ioCUIDType = 'cuidtype';
-function ImportContact(node:HXML):THANDLE;
+function ImportContact(node:HXML):HCONTACT;
var
proto:pAnsiChar;
tmpbuf:array [0..63] of AnsiChar;
@@ -352,7 +352,7 @@ begin
end;
end;
-function ImportContactINI(node:pointer):THANDLE;
+function ImportContactINI(node:pointer):HCONTACT;
{
var
proto:pAnsiChar;
@@ -441,48 +441,84 @@ type
const
actDLLCache: tDLLCache = nil;
-function GetDllHandle(dllname:pAnsiChar;mode:dword=0):THANDLE;
+function GetDllHandle(adllname:pAnsiChar;mode:dword=0):THANDLE;
var
- i:integer;
+ i,zero:integer;
begin
- result:=LoadLibraryA(dllname);
-exit;
+ // 1 - search that name in cache
i:=0;
+ zero:=-1;
while i<=HIGH(actDLLCache) do
begin
- if StrCmp(actDLLCache[i].DllName,dllname)=0 then
+ with actDLLCache[i] do
begin
- result:=actDLLCache[i].DllHandle;
- // check mode
- exit;
+ // remember first empty slot
+ if DllHandle=0 then
+ begin
+ if zero<0 then
+ zero:=i;
+ end
+ else if StrCmp(DllName,adllname)=0 then
+ begin
+ result:=DllHandle;
+ inc(count);
+ if mode=3 then // per-session
+ flags:=3;
+ exit;
+ end;
end;
inc(i);
end;
- result:=LoadLibraryA(dllname);
- // check mode
- SetLength(actDLLCache,i);
- StrDup(actDLLCache[i].DllName,dllname);
- actDLLCache[i].DllHandle:=result;
-// actDLLCache.flags:=;
+ // 2 - not found, load library
+ result:=LoadLibraryA(adllname);
+ // 3 - add to cache if not per-action
+ if mode<>0 then
+ begin
+ if zero>=0 then
+ i:=zero
+ else
+ begin
+ SetLength(actDLLCache,i);
+ dec(i);
+ end;
+
+ with actDLLCache[i] do
+ begin
+ StrDup(DllName,adllname);
+ DllHandle:=result;
+ count :=0;
+ flags :=mode;
+ end;
+ end;
end;
procedure CloseDllHandle(handle:THANDLE);
var
i:integer;
begin
- FreeLibrary(handle);
-exit;
- i:=0;
- while i<=HIGH(actDLLCache) do
+ i:=HIGH(actDLLCache);
+ while i>=0 do
begin
- if actDLLCache[i].DllHandle=handle then
+ with actDLLCache[i] do
begin
- // check mode
- FreeLibrary(actDLLCache[i].DllHandle);
- exit;
+ if DllHandle=handle then
+ begin
+ dec(count);
+ if count=0 then
+ begin
+ if flags=2 then // per-macro+not needed -> free
+ begin
+ FreeLibrary(DllHandle);
+ DllHandle:=0;
+ mFreeMem(DllName);
+ end;
+ end;
+ exit;
+ end;
end;
- inc(i);
+ dec(i);
end;
+ // if not found in cache
FreeLibrary(handle);
end;
@@ -490,10 +526,17 @@ procedure FreeDllHandleCache;
var
i:integer;
begin
- i:=0;
- while i<=HIGH(actDLLCache) do
+ i:=HIGH(actDLLCache);
+ while i>=0 do
begin
+ if actDLLCache[i].DllHandle<>0 then
+ begin
+ FreeLibrary(actDLLCache[i].DllHandle);
+ mFreeMem(actDLLCache[i].DllName);
+ end;
+ dec(i);
end;
+ SetLength(actDLLCache,0);
end;
end.