亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? qmemory.pas

?? 俄羅斯出品的一個高效字符串操作的函數單元
?? PAS
?? 第 1 頁 / 共 3 頁
字號:

//////////////////////////////////////////////////
//                                              //
//   QMemory 2.01a                              //
//                                              //
//   The alternative quick memory manager       //
//                                              //
//   Copyright (c) 2000,2001 Andrew Driazgov    //
//   e-mail: andrewdr@newmail.ru                //
//                                              //
//   Last updated: February 15, 2002            //
//                                              //
//////////////////////////////////////////////////

unit QMemory;

{$Q-}

interface

{ QMemory is a new memory manager. You can use it as a replacement of the
  default system memory manager. To do this simply add QMemory unit in your
  project (as the first unit listed in the project file). Don't forget to call
  the QMemDecommitOverstock function when your application is idle. This
  subroutine decommits the unused memory blocks (it's only way for program to
  return the memory to the operation system). All allocated memory blocks are
  32 byte aligned. The minimum size of the block is 32 bytes. As it is
  necessary to store some information with each block a dword is attached to
  the front of each block at -4 the aligned  address. Thus, memory request for
  up to 28 bytes allocates a 32-bytes block, request for 29 to 60 bytes
  allocates a 64-bytes block, etc (as power of 2). This idea was adopted from
  HPMM project of Robert Lee (rhlee@optimalcode.com). The memory is committed
  and decommitted in 64K blocks. The maximum amount of the memory is specified
  when QMemInstall function is called (from the initialization section of the
  unit). You can't change this value later. If some parts of your program
  implemented as DLLs you have to use ShareQmm instead of QMemory unit. }

(*
  QMemory should always be the first unit listed in program uses clause:

  program Project1;

  uses
    QMemory in 'QMemory.pas',        // first unit !!!
    Forms,
    MainUnit in 'MainUnit.pas' {MainForm},
    ...

  {$R *.RES}

  begin
    Application.Initialize;
    Application.Title := 'Project1';
    Application.CreateForm(TMainForm, MainForm);
    ...
    Application.Run;
  end.
*)

{ QMemInstall creates a custom heap and sets the entry points of the memory
  manager to the three functions of this unit which work with a created heap.
  The function reserves space in the virtual address space of the process and
  allocates physical storage for a specified initial portion of this block.
  InitialSize specifies the initial size, in bytes, of the heap. This value
  determines the initial amount of physical storage that is allocated for the
  heap. The value is rounded up to the next 64-kilobyte boundary. MaximumSize
  specifies the maximum size, in bytes, of the heap. The QMemInstall function
  rounds MaximumSize up to the next 512-kilobyte boundary, and then reserves
  a block of that size in the process's virtual address space for the heap.
  If allocation requests made by the GetMem or ReallocMem (or New) exceed the
  initial amount of physical storage specified by InitialSize, the system
  allocates additional pages of physical storage for the heap, up to the
  heap's maximum size. If the function succeeds, the return value is 0. If
  the function fails, it returns -1.

  QMemInstall is called from the initialization section of this unit. }

function QMemInstall(InitialSize, MaximumSize: Integer): Integer;

{ QMemRelease destroys the custom heap and restores the previous memory
  manager. QMemRelease decommits and releases all the pages of a heap. If the
  function succeeds, the return value is 0. If the function fails, the return
  value is -1.

  QMemRelease is called from the finalization section of this unit. }

function QMemRelease: Integer;

{ QMemDecommitOverstock decommits large free blocks of the memory. You may
  want to call the function from Application.Idle event handler. This function
  is only way (except QMemRelease) for decommit pages of the physical storage.
  If the function succeeds, the return value is 0, otherwise it returns -1. }

function QMemDecommitOverstock: Integer;

{ QMemSize returns the size, in bytes, of a memory block allocated from a
  custom heap. P is a pointer to the memory block whose size the function
  will obtain. The custom heap has to be installed. If the function succeeds,
  the return value is the size, in bytes, of the allocated memory block.
  If the function fails, the return value is -1. }

function QMemSize(P: Pointer): Integer;

{ QMemTotalAddrSpace returns the total address space of the custom heap,
  in bytes. This is fixed and will not grow as your program's dynamic memory
  usage grows. TotalUncommitted + TotalCommitted = TotalAddrSpace. The value
  is equal to MaximumSize, which you have specified when called QMemInstall
  function. If QMemTotalAddrSpace function fails, the return value is -1. }

function QMemTotalAddrSpace: Integer;

{ QMemTotalCommitted returns the total number of bytes (of TotalAddrSpace)
  for which space has been allocated in the swap file. If the function fails,
  the return value is -1. }

function QMemTotalCommitted: Integer;

{ QMemTotalUncommitted returns the total number of bytes (of TotalAddrSpace)
  for which space has not been allocated in the swap file. If the function
  fails, the return value is -1. }

function QMemTotalUncommitted: Integer;

{ QMemTotalAllocated returns the total number of bytes dynamically allocated
  by your program. It includes 4 bytes at the beginning of each memory block
  and the trailing bytes for maintain of 32-bytes align of a memory blocks.
  If the function fails, the return value is -1. }

function QMemTotalAllocated: Integer;

{ QMemTotalFree returns the total number of free bytes available in the
  custom heap for allocation by your program. If the function fails, the
  return value is -1. }

function QMemTotalFree: Integer;

{ QMemMaxFreeBlock returns the size, in bytes, of the maximum memory block
  which you can allocate in the custom heap. You can pass this value to
  the GetMem procedure (if you have physical storage of enought size).
  If the function fails, the return value is -1. }

function QMemMaxFreeBlock: Integer;

{ QMemCountOfFreeBlocks returns the total number of free blocks in the custom
  heap address space. If the function fails, the return value is -1. }

function QMemCountOfFreeBlocks: Integer;

{ QMemOverhead returns the total number of bytes required by the heap manager
  to manage all the blocks dynamically allocated by your program. More
  precisely, it returns the total size, in bytes, of additional committed
  space. If the function fails, the return value is -1. }

function QMemOverhead: Integer;

{ QMemGetHeapStatus returns the current status of the custom memory manager
  in a TQMemHeapStatus record. The fields of this record have been described
  above (they are analogues of the corresponding functions). If the function
  fails, all fields are 0. }

type
  TQMemHeapStatus = record
    TotalAddrSpace: Cardinal;
    TotalCommitted: Cardinal;
    TotalUncommitted: Cardinal;
    TotalAllocated: Cardinal;
    TotalFree: Cardinal;
    MaxFreeBlock: Cardinal;
    CountOfFreeBlocks: Cardinal;
    Overhead: Cardinal;
  end;

function QMemGetHeapStatus: TQMemHeapStatus;

{ QMemSetMaxECount assigns a new value to the internal variable which limits
  maximum number of free fragments in the custom heap. The default value is
  65536. If you want to save some virtual address space you may set this
  variable less (or more, if it is necessary). This function should be called
  before QMemInstall (when the memory manager is not installed yet). If the
  function succeeds, it returns 0. If the function fails, it returns -1. }

function QMemSetMaxECount(Value: Integer): Integer;

implementation

uses Windows;

type
  PEntryPoint = ^TEntryPoint;
  TEntryPoint = packed record
    Address: LongWord;
    Space: LongWord;
    AdrLeft: PEntryPoint;
    AdrRight: PEntryPoint;
    SpLeft: PEntryPoint;
    SpRight: PEntryPoint;
  end;

  PEFreeArr = ^TEFreeArr;
  TEFreeArr = array[0..$7FFFFF] of PEntryPoint;

var
  lpCriticalSection:_RTL_CRITICAL_SECTION;

  ListLeft: PEntryPoint;
  ListRight: PEntryPoint;

  SizeTable: array[0..30] of PEntryPoint;

  EFreeCount: Integer;
  EFreeArr: PEFreeArr;

  StartAddr: LongWord;
  SpaceBegin: LongWord;

  MaxECount: Integer = $10000;

  QMemIsInstalled: Boolean = False;

  OldMemManager: TMemoryManager;

function GetNormalSize(Size: Integer): Integer;
asm
        ADD     EAX,3
        TEST    EAX,$FFFFFFE0
        JE      @@sm
        BSR     ECX,EAX
        MOV     EAX,2
        SHL     EAX,CL
        RET
@@sm:   MOV     EAX,32
end;

function GetRegionOfSize(Size: Integer): Pointer;
asm
        BSF     ECX,EAX
        LEA     EDX,[ECX*4+SizeTable]
        MOV     ECX,[EDX]
        TEST    ECX,ECX
        JE      @@nx
        MOV     EAX,ECX
        MOV     ECX,[ECX].TEntryPoint.SpRight
        MOV     [EDX],ECX
        TEST    ECX,ECX
        JE      @@qm
        XOR     EDX,EDX
        MOV     [ECX].TEntryPoint.SpLeft,EDX
@@qm:   RET
@@nx:   MOV     EDX,EAX
        MOV     EAX,ListLeft
        TEST    EAX,EAX
        JE      @@qt
@@lp:   CMP     EDX,[EAX].TEntryPoint.Space
        JLE     @@qt
        MOV     EAX,[EAX].TEntryPoint.AdrRight
        TEST    EAX,EAX
        JNE     @@lp
@@qt:
end;

function IntBitTest(P: Pointer; Index: Integer): Boolean;
asm
        BT      [EAX],EDX
        SETC    AL
end;

procedure IntBitSet(P: Pointer; Index: Integer);
asm
        BTS     [EAX],EDX
end;

function IntFreeBitScanForward(P: Pointer; FirstBit, LastBit: Integer): Integer;
asm
        PUSH    EBX
        PUSH    ESI
        PUSH    EDI
        LEA     ESI,[EDX+8]
        CMP     ECX,ESI
        JL      @@ut
        MOV     EBX,$FFFFFFFF
        MOV     ESI,ECX
        MOV     EDI,$0000001F
        AND     ECX,EDI
        AND     ESI,$FFFFFFE0
        SUB     EDI,ECX
        SHR     ESI,5
        MOV     ECX,EDI
        MOV     EDI,EBX
        SHR     EDI,CL
        MOV     ECX,EDX
        AND     EDX,$FFFFFFE0
        AND     ECX,$0000001F
        SHR     EDX,5
        SHL     EBX,CL
        MOV     ECX,[EAX+EDX*4]
        NOT     ECX
        AND     EBX,ECX
        SUB     ESI,EDX
        JE      @@nq
        TEST    EBX,EBX
        JNE     @@ne
        INC     EDX
        DEC     ESI
        JE      @@xx
@@lp:   MOV     EBX,[EAX+EDX*4]
        NOT     EBX
        TEST    EBX,EBX
        JNE     @@ne
        INC     EDX
        DEC     ESI
        JNE     @@lp
@@xx:   MOV     EBX,[EAX+EDX*4]
        NOT     EBX
@@nq:   AND     EBX,EDI
        JE      @@zq
@@ne:   BSF     ECX,EBX
@@qt:   SHL     EDX,5
        LEA     EAX,[ECX+EDX]
        POP     EDI
        POP     ESI
        POP     EBX
        RET
@@ut:   SUB     ECX,EDX
        JS      @@zq
@@uk:   BT      [EAX],EDX
        JNC     @@iq
        INC     EDX
        DEC     ECX
        JNS     @@uk
@@zq:   MOV     EAX,$FFFFFFFF
        POP     EDI
        POP     ESI
        POP     EBX
        RET
@@iq:   MOV     EAX,EDX
        POP     EDI
        POP     ESI
        POP     EBX
end;

function IntFreeBitScanReverse(P: Pointer; FirstBit, LastBit: Integer): Integer;
asm
        PUSH    EBX
        PUSH    ESI
        PUSH    EDI
        LEA     ESI,[EDX+8]
        CMP     ECX,ESI
        JL      @@ut
        MOV     EBX,$FFFFFFFF
        MOV     ESI,ECX
        MOV     EDI,$0000001F
        AND     ECX,EDI
        AND     ESI,$FFFFFFE0
        SUB     EDI,ECX
        SHR     ESI,5
        MOV     ECX,EDI
        MOV     EDI,EBX
        SHR     EDI,CL
        MOV     ECX,EDX
        AND     EDX,$FFFFFFE0
        AND     ECX,$0000001F
        SHR     EDX,5
        SHL     EBX,CL
        MOV     ECX,[EAX+ESI*4]
        NOT     ECX
        AND     EDI,ECX
        SUB     EDX,ESI
        JE      @@nq
        TEST    EDI,EDI
        JNE     @@ne
        NEG     EDX
        DEC     ESI
        DEC     EDX
        JE      @@xx
@@lp:   MOV     EDI,[EAX+ESI*4]
        NOT     EDI
        TEST    EDI,EDI
        JNE     @@ne
        DEC     ESI
        DEC     EDX
        JNE     @@lp
@@xx:   MOV     EDI,[EAX+ESI*4]
        NOT     EDI
@@nq:   AND     EDI,EBX
        JE      @@zq
@@ne:   BSR     ECX,EDI
@@qt:   SHL     ESI,5
        LEA     EAX,[ECX+ESI]
        POP     EDI
        POP     ESI
        POP     EBX
        RET
@@ut:   SUB     EDX,ECX
        JG      @@zq
@@uk:   BT      [EAX],ECX
        JNC     @@iq
        DEC     ECX
        INC     EDX
        JNG     @@uk
@@zq:   MOV     EAX,$FFFFFFFF
        POP     EDI
        POP     ESI
        POP     EBX
        RET
@@iq:   MOV     EAX,ECX
        POP     EDI
        POP     ESI
        POP     EBX
end;

procedure IntSetBits(P: Pointer; FirstBit, LastBit: Integer);
asm
        PUSH    EDI
        PUSH    ESI
        PUSH    EBX
        LEA     ESI,[EDX+8]
        CMP     ECX,ESI
        JL      @@ut
        MOV     EBX,$FFFFFFFF
        MOV     ESI,ECX
        MOV     EDI,$0000001F
        AND     ECX,EDI
        AND     ESI,$FFFFFFE0
        SUB     EDI,ECX
        SHR     ESI,5
        MOV     ECX,EDI
        MOV     EDI,EBX
        SHR     EDI,CL
        MOV     ECX,EDX
        AND     EDX,$FFFFFFE0
        AND     ECX,$0000001F
        SHR     EDX,5
        SHL     EBX,CL
        SUB     ESI,EDX
        JE      @@xx
        OR      [EAX+EDX*4],EBX
        INC     EDX
        DEC     ESI
        JE      @@ne
        MOV     EBX,$FFFFFFFF
@@lp:   MOV     [EAX+EDX*4],EBX
        INC     EDX
        DEC     ESI
        JNE     @@lp
@@xx:   AND     EDI,EBX
@@ne:   OR      [EAX+EDX*4],EDI
        POP     EBX
        POP     ESI
        POP     EDI
        RET
@@ut:   SUB     ECX,EDX
        JS      @@qt
@@uk:   BTS     [EAX],EDX
        INC     EDX
        DEC     ECX
        JNS     @@uk
@@qt:   POP     EBX
        POP     ESI
        POP     EDI
end;

procedure DelFromSizeTable(E: PEntryPoint);
asm
        MOV     EDX,[EAX].TEntryPoint.SpLeft
        TEST    EDX,EDX
        JNE     @@nx
        MOV     EDX,[EAX].TEntryPoint.Space
        BSF     ECX,EDX
        LEA     EDX,[ECX*4+SizeTable]
        CMP     EAX,[EDX]
        JNE     @@qt
        MOV     ECX,[EAX].TEntryPoint.SpRight
        MOV     [EDX],ECX
        TEST    ECX,ECX
        JE      @@qt
        XOR     EDX,EDX
        MOV     [ECX].TEntryPoint.SpLeft,EDX
@@qt:   RET
@@nx:   MOV     ECX,[EAX].TEntryPoint.SpRight
        MOV     [EDX].TEntryPoint.SpRight,ECX
        TEST    ECX,ECX
        JE      @@qx
        MOV     [ECX].TEntryPoint.SpLeft,EDX
@@qx:
end;

function IntGetMem(Size: Integer): Pointer;
label
  99;
var
  E: PEntryPoint;
  I,J: Integer;
begin
  try
    if IsMultiThread then
      EnterCriticalSection(lpCriticalSection);
    Size := GetNormalSize(Size);
    E := GetRegionOfSize(Size);
    if E <> nil then
    begin

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久美女艺术照精彩视频福利播放| 亚洲永久免费av| 亚洲欧美福利一区二区| 免费观看在线色综合| 成人影视亚洲图片在线| 欧美一区二区日韩| 一区在线观看免费| 久久se这里有精品| 欧美乱妇20p| 亚洲久草在线视频| 国产精品资源在线观看| 日韩一区二区三区免费看| 亚洲另类中文字| av中文字幕亚洲| 久久久久久久精| 另类小说图片综合网| 欧美日韩久久一区| 亚洲一区二区三区激情| 成人18精品视频| 中文字幕成人在线观看| 国产一区二区按摩在线观看| 日韩一区国产二区欧美三区| 午夜不卡在线视频| 91精品午夜视频| 亚洲国产欧美日韩另类综合| 91麻豆国产精品久久| 国产精品美女久久福利网站| 国产精品88888| 久久久夜色精品亚洲| 国产精品综合在线视频| 久久综合色一综合色88| 国内精品在线播放| 久久品道一品道久久精品| 精品一区二区三区在线观看国产| 欧美一区二区三区免费观看视频| 午夜精品福利在线| 51午夜精品国产| 美女被吸乳得到大胸91| 日韩欧美一级精品久久| 紧缚奴在线一区二区三区| 精品成人在线观看| 丁香亚洲综合激情啪啪综合| 国产精品久久久久久久久晋中 | 国产亚洲精品7777| 国产91精品在线观看| 国产精品蜜臀av| 色婷婷久久综合| 午夜伊人狠狠久久| 欧美一区二区国产| 紧缚捆绑精品一区二区| 亚洲欧洲色图综合| 欧美视频完全免费看| 蜜乳av一区二区三区| 亚洲国产高清aⅴ视频| 日本高清不卡在线观看| 日韩精品一级中文字幕精品视频免费观看 | 成人精品电影在线观看| 亚洲免费在线视频一区 二区| 欧美性大战xxxxx久久久| 天涯成人国产亚洲精品一区av| 日韩一级片网址| 成人深夜在线观看| 一区二区三区不卡视频| 欧美成人艳星乳罩| 91免费视频观看| 免费在线成人网| 中文字幕av一区二区三区| 91丨九色丨黑人外教| 免费成人美女在线观看| 国产精品美女久久久久久| 欧美少妇xxx| 国产**成人网毛片九色 | 国产精品久久国产精麻豆99网站| 欧美日韩和欧美的一区二区| 国产麻豆精品一区二区| 夜夜嗨av一区二区三区中文字幕| 日韩欧美国产综合在线一区二区三区| www..com久久爱| 美女视频黄a大片欧美| 午夜亚洲国产au精品一区二区| 国产香蕉久久精品综合网| 欧美日韩国产a| 91香蕉视频在线| 国产成人高清在线| 视频在线观看一区二区三区| 国产精品国产三级国产aⅴ无密码| 欧美一卡二卡三卡| 在线观看日韩毛片| av毛片久久久久**hd| 精品一区二区三区日韩| 亚洲成人黄色小说| 亚洲人成影院在线观看| 国产欧美日韩另类一区| 日韩视频免费观看高清在线视频| 色婷婷久久99综合精品jk白丝| 国产一区二区调教| 麻豆精品视频在线观看视频| 亚洲图片欧美色图| 亚洲精品视频在线看| 中文字幕精品综合| 国产性色一区二区| 久久影音资源网| 337p粉嫩大胆噜噜噜噜噜91av | 亚洲一区av在线| 国产精品不卡一区二区三区| 久久久久久久久久久久电影| 久久综合色播五月| 欧美精品一区二区三区一线天视频 | 亚洲一区二区三区国产| 亚洲精品中文在线观看| 最新成人av在线| 亚洲欧洲精品一区二区三区不卡| 国产日产欧美一区二区三区| 久久久久国产精品人| 国产午夜精品久久久久久免费视| 久久在线免费观看| 久久久亚洲精华液精华液精华液| 久久这里只有精品6| 国产午夜精品一区二区| 欧美国产精品劲爆| 国产精品网曝门| 亚洲日本va午夜在线影院| 成人欧美一区二区三区1314| 日韩理论片中文av| 亚洲精品国产一区二区三区四区在线| 亚洲三级理论片| 亚洲一区二区三区影院| 亚洲成av人片在线| 美女视频一区二区| 懂色av中文字幕一区二区三区| jizz一区二区| 色一情一乱一乱一91av| 欧美视频一区二区| 亚洲视频免费观看| 亚洲国产日韩在线一区模特| 日本中文字幕一区二区视频| 精品一区二区在线免费观看| 国产suv一区二区三区88区| 色综合久久88色综合天天 | 26uuu国产日韩综合| 久久精品男人的天堂| 1024成人网色www| 午夜免费久久看| 极品少妇一区二区| 99精品久久久久久| 在线一区二区三区做爰视频网站| 制服视频三区第一页精品| 久久精品人人做人人综合 | 欧美色涩在线第一页| 欧美xxxx在线观看| 国产精品超碰97尤物18| 婷婷综合五月天| 国产aⅴ综合色| 欧美日韩国产影片| 欧美激情在线免费观看| 午夜久久久影院| 国产一区亚洲一区| 欧美性生活大片视频| 欧美国产精品一区二区三区| 日韩成人免费在线| 97精品电影院| 精品国免费一区二区三区| 成人免费视频在线观看| 激情亚洲综合在线| 欧美亚一区二区| 国产亚洲精品bt天堂精选| 日本女人一区二区三区| 不卡视频在线看| 精品日产卡一卡二卡麻豆| 亚洲国产欧美在线| aa级大片欧美| 国产三级欧美三级日产三级99| 无码av免费一区二区三区试看 | bt7086福利一区国产| 久久综合色婷婷| 三级影片在线观看欧美日韩一区二区 | 日韩亚洲欧美成人一区| 一区二区三区小说| 国产成人小视频| 精品国产伦一区二区三区免费| 亚洲成年人网站在线观看| 色哟哟国产精品| 成人免费在线视频| 99久久综合99久久综合网站| 久久亚区不卡日本| 美女网站一区二区| 欧美一二三四在线| 日韩高清一级片| 欧美日韩二区三区| 午夜伦欧美伦电影理论片| 欧美日韩日日摸| 亚洲码国产岛国毛片在线| 成人激情图片网| 国产精品国产三级国产三级人妇| 国产福利一区二区三区视频| 久久综合色综合88| 国产成人综合视频| 国产网站一区二区| 国产精品中文字幕日韩精品 | 亚洲色图20p|