Просмотр исходного кода

+ Added FillXXX and IndexXXX functions

michael 25 лет назад
Родитель
Сommit
9c162d1f67
1 измененных файлов с 110 добавлено и 5 удалено
  1. 110 5
      docs/ref.tex

+ 110 - 5
docs/ref.tex

@@ -4747,11 +4747,17 @@ Functions concerning memory issues.
 \begin{funclist}
 \funcref{Addr}{Return address of variable}
 \funcref{Assigned}{Check if a pointer is valid}
+\funcref{CompareByte}{Compare 2 memory buffers byte per byte}
+\funcref{CompareChar}{Compare 2 memory buffers byte per byte}
+\funcref{CompareDWord}{Compare 2 memory buffers byte per byte}
+\funcref{CompareWord}{Compare 2 memory buffers byte per byte}
 \funcref{CSeg}{Return code segment}
 \procref{Dispose}{Free dynamically allocated memory}
 \funcref{DSeg}{Return data segment}
+\procref{FillByte}{Fill memory region with 8-bit pattern}
 \procref{Fillchar}{Fill memory region with certain character}
-\procref{Fillword}{Fill memory region with 16 bit pattern}
+\procref{FillDWord}{Fill memory region with 32-bit pattern}
+\procref{Fillword}{Fill memory region with 16-bit pattern}
 \procref{Freemem}{Release allocated memory}
 \procref{Getmem}{Allocate new memory}
 \procref{GetMemoryManager}{Return current memory manager}
@@ -5464,6 +5470,27 @@ None.
 
 \FPCexample{ex24}
 
+\begin{procedure}{FillByte}
+\Declaration
+Procedure FillByte(var X;Count:longint;Value:byte);
+\Description
+\var{FillByte} fills the memory starting at \var{X} with \var{Count} bytes
+with value equal to \var{Value}.
+
+This is useful for quickly zeroing out a memory location. If you know
+that the size of the memory location to be filled out is a multiple of
+2 bytes, it is better to use \seep{Fillword}, and if it is a multiple 
+of 4 bytes it's better to use \seep{FillDWord}, these routines are 
+optimized for their respective sizes.
+
+\Errors
+No checking on the size of \var{X} is done.
+\SeeAlso
+\seep{Fillchar}, \seep{FillDWord}, \seep{Fillword}, \seep{Move}
+\end{procedure}
+
+\FPCexample{ex102}
+
 \begin{procedure}{Fillchar}
 \Declaration
 Procedure Fillchar (Var X;Count : Longint;Value : char or byte);;
@@ -5475,19 +5502,32 @@ or characters with value equal to \var{Value}.
 \Errors
 No checking on the size of \var{X} is done.
 \SeeAlso
-\seep{Fillword}, \seep{Move}
+\seep{Fillword}, \seep{Move}, \seep{FillByte}, \seep{FillDWord}
 \end{procedure}
 
 \FPCexample{ex25}
 
+\begin{procedure}{FillDWord}
+\Declaration
+Procedure FillDWord (Var X;Count : Longint;Value : DWord);;
+\Description
+\var{Fillword} fills the memory starting at \var{X} with \var{Count} DWords
+with value equal to \var{Value}. A DWord is 4 bytes in size.
+
+\Errors
+No checking on the size of \var{X} is done.
+\SeeAlso
+\seep{FillByte}, \seep{Fillchar}, \seep{Fillword}, \seep{Move}
+\end{procedure}
+
+\FPCexample{ex103}
+
 \begin{procedure}{Fillword}
 \Declaration
 Procedure Fillword (Var X;Count : Longint;Value : Word);;
-
 \Description
 \var{Fillword} fills the memory starting at \var{X} with \var{Count} words
-with value equal to \var{Value}.
-
+with value equal to \var{Value}. A word is 2 bytes in size.
 \Errors
 No checking on the size of \var{X} is done.
 \SeeAlso
@@ -5678,6 +5718,70 @@ error, if you try to increase \var{X} over its maximum value.
 
 \FPCexample{ex32}
 
+\begin{function}{IndexByte}
+\Declaration
+function  IndexByte(var buf;len:longint;b:byte):longint;  
+\Description
+\var{IndexByte} searches the memory at \var{buf} for maximally \var{len}
+positions for the byte \var{b} and returns it's position if it found one.
+If \var{b} is not found then -1 is returned.
+
+The position is zero-based.
+\Errors
+\var{Buf} and \var{Len} are not checked to see if they are valid values.
+\SeeAlso
+\seef{IndexChar}, \seef{IndexDWord}, \seef{IndexWord}, \seef{CompareByte}
+\end{function}
+
+\FPCexample{ex105}
+
+\begin{function}{IndexChar}
+\Declaration
+function  IndexChar(var buf;len:longint;b:char):longint;  
+\Description
+\var{IndexChar} searches the memory at \var{buf} for maximally \var{len}
+positions for the character \var{b} and returns it's position if it found one.
+If \var{b} is not found then -1 is returned.
+
+The position is zero-based.
+\Errors
+\var{Buf} and \var{Len} are not checked to see if they are valid values.
+\SeeAlso
+\seef{IndexByte}, \seef{IndexDWord}, \seef{IndexWord}, \seef{CompareChar}
+\end{function}
+
+\FPCexample{ex108}
+
+\begin{function}{IndexDWord}
+\Declaration
+function  IndexDWord(var buf;len:longint;DW:DWord):longint;
+\var{IndexChar} searches the memory at \var{buf} for maximally \var{len}
+positions for the DWord \var{DW} and returns it's position if it found one.
+If \var{DW} is not found then -1 is returned.
+
+The position is zero-based.
+\Errors
+\var{Buf} and \var{Len} are not checked to see if they are valid values.
+\SeeAlso
+\seef{IndexByte}, \seef{IndexChar}, \seef{IndexWord}, \seef{CompareDWord}
+\end{function}
+
+\FPCexample{ex106}
+
+\begin{function}{IndexWord}
+\Declaration
+function  IndexWord(var buf;len:longint;W:word):longint;  
+\var{IndexChar} searches the memory at \var{buf} for maximally \var{len}
+positions for the Word \var{W} and returns it's position if it found one.
+If \var{W} is not found then -1 is returned.
+\Errors
+\var{Buf} and \var{Len} are not checked to see if they are valid values.
+\SeeAlso
+\seef{IndexByte}, \seef{IndexDWord}, \seef{IndexChar}, \seef{CompareWord}
+\end{function}
+
+\FPCexample{ex107}
+
 \begin{procedure}{Insert}
 \Declaration
 Procedure Insert (Const Source : String;var S : String;Index : Longint);
@@ -5694,6 +5798,7 @@ None.
 \end{procedure}
 
 \FPCexample{ex33}
+
 \begin{function}{IsMemoryManagerSet}
 \Declaration
 function  IsMemoryManagerSet: Boolean;