TailBite specific forum
Moderators: gnozal , ABBKlaus , lexvictory
Mistrel
Addict
Posts: 3415 Joined: Sat Jun 30, 2007 8:04 pm
Post
by Mistrel » Tue May 27, 2008 2:48 am
This worked fine in 4.10 and whatever TailBite version I was using before.
TailBite code:
Code: Select all
ProcedureDLL.s TB_Test()
ProcedureReturn "Anything"
EndProcedure
PureBasic code:
Code: Select all
Procedure This()
Debug TB_Test()
EndProcedure ; crashes here
This()
It does not crash if it is not called from within a procedure:
I think this is the same problem from this report:
http://www.purebasic.fr/english/viewtopic.php?t=30840
npath
User
Posts: 74 Joined: Tue Feb 15, 2005 5:15 pm
Post
by npath » Mon Jul 07, 2008 6:11 pm
This problem is listed as "Done". However, I am having the same issue with tailbite. I keep getting "invalid memory access" errors, even with simple procedures. I am using the latest version of Tailbite and PB 4.2 (Windows XP pro and Vista Ultimate). Anyone else having this problem?
ABBKlaus
Addict
Posts: 1143 Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany
Post
by ABBKlaus » Tue Jul 08, 2008 7:53 am
npath wrote: This problem is listed as "Done". However, I am having the same issue with tailbite. I keep getting "invalid memory access" errors, even with simple procedures. I am using the latest version of Tailbite and PB 4.2 (Windows XP pro and Vista Ultimate). Anyone else having this problem?
You are propably calling some exported string functions from inside the library ?
But without a snippet i´m only guessing.
npath
User
Posts: 74 Joined: Tue Feb 15, 2005 5:15 pm
Post
by npath » Tue Jul 08, 2008 6:47 pm
I believe you are right. My problem is with this procedure:
Code: Select all
ProcedureDLL.l ParseString(stringToParse.s, arrayToFill.s(1), delimiter.s) ; Parse a string into an array using a delimiter. Returns count.
; Source: Uses code posted by pdwyer
; http://www.purebasic.fr/english/viewtopic.php?t=31044&highlight=split+string
Structure MemoryArray
Byte.c[0]
word.w[0]
EndStructure
FindLen.l = Len(delimiter)
MainLen.l = Len(stringToParse)
arrayToFill.s(0)
StringCount.l = 0
*MainByteArray.MemoryArray = @stringToParse ;*MainMem
*FindByteArray.MemoryArray = @delimiter ;*FindMem
PrevPos.l = 1
; Build BadChr Array
Dim BadChar.l(255)
; set all alphabet to max shift pos (length of find string plus 1)
For i = 0 To 255
BadChar(i) = FindLen + 1
Next
;Update chars that are in the find string to their position from the end.
For i = 0 To FindLen -1
BadChar(*FindByteArray\Byte[i]) = FindLen - i
Next
MainArrayLoop.l = 1
EndSearchPos.l = MainLen - (FindLen -1)
While MainArrayLoop <= EndSearchPos
If CompareMemory(@stringToParse + MainArrayLoop, @delimiter, FindLen) = 1
FoundPos = MainArrayLoop + 1
Redim arrayToFill.s(StringCount )
;emulate fast mid() function inline,
If FoundPos - PrevPos > 0
*RetMem = AllocateMemory(FoundPos - PrevPos)
CopyMemory(@stringToParse + PrevPos -1, *RetMem, FoundPos - PrevPos)
MidStr.s = PeekS(*RetMem,FoundPos - PrevPos)
FreeMemory(*RetMem)
Else
MidStr.s = ""
EndIf
arrayToFill(StringCount) = MidStr
StringCount = StringCount + 1
PrevPos = FoundPos + FindLen
EndIf
;Didn't find the string so shift as per the table.
MainArrayLoop + BadChar(*MainByteArray.MemoryArray\Byte[MainArrayLoop + FindLen])
Wend
;catch end
Redim arrayToFill.s(StringCount)
arrayToFill(StringCount) = Mid(stringToParse, PrevPos, MainLen - PrevPos +1)
StringCount = StringCount + 1
Redim arrayToFill.s(StringCount)
ProcedureReturn StringCount
EndProcedure