Class StrList
Private
dim pStr as *BytePtr
dim nHasStr as long
dim nShowed as long
Public
sub StrList()
pStr=malloc(sizeof(Byte)*256)
nHasStr=0
nShowed=0
end sub
sub ~StrList()
dim i as Long
for i = 0 to nHasStr-1
free(pStr)
next i
free(pStr)
end sub
function GetnHasStr() as Long
GetnStr=nHasStr
end function
function PutStr(ss as BytePtr)as long
dim q as *BytePtr
dim i as Long
if nHasStr>=2000000000 then
PutStr=-1
Exit Function
elseif nHasStr mod 256 = 0 then
q=pStr
pStr=malloc(sizeof(Byte)*(nHasStr+256))
for i=0 to nHasStr-1
pStr=q
next i
End if
pStr[nHasStr]=malloc(sizeof(Byte)*lstrlen(ss))
lstrcpy(pStr[nHasStr],ss)
nHasStr=nHasStr+1
PutStr=nHasStr
end function
function GetStr(ss as BytePtr)as long
if nShowed>=nHasStr then
GetStr=-1
else
strcpy(ss,pStr[nShowed])
GetStr=0
end if
end function
end class
> Class StrList
> Private
> dim pStr as *BytePtr
> dim nHasStr as long
> dim nShowed as long
> Public
> sub StrList()
> pStr=malloc(sizeof(Byte)*256)
> nHasStr=0
> nShowed=0
> end sub
>
> sub ~StrList()
> dim i as Long
> for i = 0 to nHasStr-1
> free(pStr)
> next i
> free(pStr)
> end sub
>
>
> function GetnHasStr() as Long
> GetnStr=nHasStr
> end function
>
> function PutStr(ss as BytePtr)as long
> dim q as *BytePtr
> dim i as Long
>
> if nHasStr>=2000000000 then
> PutStr=-1
> Exit Function
> elseif nHasStr mod 256 = 0 then
> q=pStr
> pStr=malloc(sizeof(Byte)*(nHasStr+256))
> for i=0 to nHasStr-1
> pStr=q
> next i
> End if
>
> pStr[nHasStr]=malloc(sizeof(Byte)*lstrlen(ss))
> lstrcpy(pStr[nHasStr],ss)
> nHasStr=nHasStr+1
> PutStr=nHasStr
> end function
>
> function GetStr(ss as BytePtr)as long
> if nShowed>=nHasStr then
> GetStr=-1
> else
> strcpy(ss,pStr[nShowed])
> GetStr=0
> end if
> end function
> end class
>