Qbasicnews.com

Full Version: What the hell?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
By commenting blocks I got an error down to one sub call. So I tried using comment blocks to find the error in the sub. I ended up commenting the entire sub out and it still doesn't run. If I take out the sub call it works. THERE IS NO CODE IN THE SUB! What could cause something like this? If you want to see code I'll post it but I don't think it will matter.

Anonymous

Of course it will matter.

Post the code.

Also, what version are you using? The current testing release is .17.
Nevermind, it was a bad pointer. I thought code wouldn't matter because I had commented everything out except for this part.

sub loadskin (s as skin ptr)
loadskin1(s->skin1)

and I forgot to allocate s. Don't you just hate when you spend two days trying to figure out what's wrong then it smacks you in the head?
New question: If I have a sub that allocates memory and I don't want it to allocate something twice (create an orphan,) can I deallocate first?

sub foo (s as sometype ptr)
deallocate s
s = allocate (len(sometype));
end sub

if I send it a blank pointer will the deallocate mess something up? It's basically doing the same as:

dim s as sometype ptr
deallocate s

Anonymous

deallocate( 0 ) does nothing, so your example will function normally.

if in doubt, try

Code:
if s then

  deallocate s

end if

"if s" breaks down to "if s <> 0"
Cha0s, have you put me on ignore? Sad
You shouldn't free null pointers. You should also specify "ByRef" explicitly if that's what you want; otherwise, it's not clear to the reader, and it will break when you switch to -lang fb.