Bug with AllocateMemory

Just starting out? Need help? Post your questions and find answers here.
lionel_om
User
User
Posts: 31
Joined: Wed Jul 18, 2007 4:14 pm
Location: France

Post by lionel_om »

Pupil wrote:
lionel_om wrote: But with using "*mem\s = *str\s", PB made the copy and create a new buffer . Or I'm wrong...?
No, you're quite right.
PB's way of handling the '@' operator for strings can be a bit confusing at times. :) As you can se from the different answers you're getting ;)
So my procedure is quite good, excepted the null pointer case ?!

Code: Select all

Procedure.l V__Constructor_String(*param = #Null)
  Protected *str.String, *mem.String
  *mem = Vector__Allocate(SizeOf(String))
  If *param
    *str = @*param
    *mem\s = *str\s
  Else
    *mem\s = ""
  EndIf
  ProcedureReturn *mem
EndProcedure
So the problem came from another place ?! :?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

lionel_om wrote: So my procedure is quite good, excepted the null pointer case ?!

So the problem came from another place ?! :?
Yes i think the procedure is just fine, so there might be another problem somewhere in the code. One thing i wonder though, how is the result from the string constructor procedure handled?
lionel_om
User
User
Posts: 31
Joined: Wed Jul 18, 2007 4:14 pm
Location: France

Post by lionel_om »

Pupil wrote:
lionel_om wrote: So my procedure is quite good, excepted the null pointer case ?!

So the problem came from another place ?! :?
Yes i think the procedure is just fine, so there might be another problem somewhere in the code. One thing i wonder though, how is the result from the string constructor procedure handled?
The return is used has a pointer of a STRING structure :

Code: Select all

*a.STRING = CallMyFunction()
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

That should be OK.

Sorry, i'm afraid you have to do some more bug hunting :(

Are you using any threads or are the code compiled into a DLL?
lionel_om
User
User
Posts: 31
Joined: Wed Jul 18, 2007 4:14 pm
Location: France

Post by lionel_om »

Pupil wrote:That should be OK.

Sorry, i'm afraid you have to do some more bug hunting :(

Are you using any threads or are the code compiled into a DLL?
Yeah, I'm using Threads, and the only way the program bug is in the Threaded functions. I hope that PB have no more bug with threads and strings.

PS : I'have checked "Thread safe" in compiler options.

Lio
Post Reply