[résolue][Linux] problem avec objectmanager.a
Publié : lun. 13/août/2007 22:27
j'ai essayé de convertir le code de dri pour linux
http://www.purebasic.fr/french/viewtopi ... ght=object
sa compile et se lance mais tous ce que j'obtient c'est un invalid memory acces ....
http://www.purebasic.fr/french/viewtopi ... ght=object
sa compile et se lance mais tous ce que j'obtient c'est un invalid memory acces ....
Code : Tout sélectionner
CompilerIf #PB_Compiler_Thread ;>
#ObjectManager = "compilers/objectmanagerthread.a"
CompilerElse ;=
#ObjectManager = "compilers/objectmanager.a"
CompilerEndIf;<
Import #PB_Compiler_Home + #ObjectManager
Object_GetOrAllocate (Objects, Object.l) As "PB_Object_GetOrAllocateID"
Object_GetObject (Objects, Object.l) As "PB_Object_GetObject"
Object_IsObject (Objects, Object.l) As "PB_Object_IsObject"
Object_EnumerateAll (Objects, ObjectEnumerateAllCallback, *VoidData) As "PB_Object_EnumerateAll"
Object_EnumerateStart (Objects) As "PB_Object_EnumerateStart"
Object_EnumerateNext (Objects, *object.Long) As "PB_Object_EnumerateNext"
Object_EnumerateAbort (Objects) As "PB_Object_EnumerateAbort"
Object_Free (Objects, Object.l) As "PB_Object_FreeID"
Object_Init (StructureSize.l, IncrementStep.l, ObjectFreeFunction) As "PB_Object_Init"
Object_GetThreadMemory (MemoryID.l) As "PB_Object_GetThreadMemory"
Object_InitThreadMemory(Size.l, InitFunction, EndFunction) As "PB_Object_InitThreadMemory"
EndImport
Prototype ObjectFreeFunction(Object.l)
Structure PB_SimpleList
*Next .PB_SimpleList
*Previous.PB_SimpleList
EndStructure
Structure CRITICAL_SECTION
Par1.l
Par2.l
Par3.l
Par4.l
Par5.l
Par6.l
EndStructure
Structure PB_Object
;
StructureSize.l
IncrementStep.l
ObjectsNumber.l
*ListFirstElement.PB_SimpleList
;
FreeObject.ObjectFreeFunction
;
Current.l
*CurrentElement.PB_SimpleList
;
CompilerIf #PB_Compiler_Thread ;>
IncrementShift.l
*FirstObjectsArea.PB_SimpleList
*LastObjectsArea .PB_SimpleList
ObjectMutex.CRITICAL_SECTION
CompilerElse ;=
*ObjectsArea
CompilerEndIf ;<
;
EndStructure
Structure TEST
TEST.l
EndStructure
Declare freeobject(object.l)
Global obj = Object_Init(SizeOf(TEST), 1, @freeobject())
Procedure NewObject()
Protected *this.TEST = Object_GetOrAllocate(obj, #PB_Any)
If *this
*this/TEST = 10
EndIf
ProcedureReturn *this
EndProcedure
Procedure freeobject(object.l)
EndProcedure
obj = NewObject()