freeimage() needed before copyimage()
freeimage() needed before copyimage()
Let's say #image1 is an image, but I issues CopyImage(#image2, #image1) --- is the memory automatically freed, or should I be calling freeimage 1st?
Re: freeimage() needed before copyimage()
Clean programming means: If you take something, you give it back when it is no longer needed.
A programming language cannot see into the programmer's head to guess what he is going to do next.
But in this case : If #Image1 is a fixed number (and not created with #PB_Any) then it is released.
At least that's what everyone has said so far...
(translated by DeepL.com)
A programming language cannot see into the programmer's head to guess what he is going to do next.
But in this case : If #Image1 is a fixed number (and not created with #PB_Any) then it is released.
At least that's what everyone has said so far...
(translated by DeepL.com)
Re: freeimage() needed before copyimage()
Hello,
Code: Select all
Enumeration
#image1
#Image2
EndEnumeration
; Example 1 : When #Image2 doesn't exist
CreateImage(#image1,50,50)
CopyImage(#image1,#Image2)
Debug IsImage(#Image2)
; Example 2 : When #Image2 already exists
ResizeImage(#Image2,1,1)
CopyImage(#image1,#Image2)
Debug IsImage(#Image2)
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Except on this sentence...
Re: freeimage() needed before copyimage()
PB-Help: https://www.purebasic.com/documentation ... jects.html
- An object that is associated with an index is automatically freed when reusing that index.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: freeimage() needed before copyimage()
Yes, I understand that. Yet, purebasic does some things "automatically" ... I realized I hadn't free'd the images, and wondered if I needed to go back into the code and change it. I don't regularly work with images... I was hoping copyimage would free the destination if it exists.Bisonte wrote: Wed May 29, 2024 7:31 am Clean programming means: If you take something, you give it back when it is no longer needed.
However, if you're copying #iamge1 to #image2 - the language could know #image2 is no longer needed.Bisonte wrote: Wed May 29, 2024 7:31 am A programming language cannot see into the programmer's head to guess what he is going to do next.
Last edited by jassing on Wed May 29, 2024 12:25 pm, edited 1 time in total.
Re: freeimage() needed before copyimage()
Thank you.mk-soft wrote: Wed May 29, 2024 8:25 am PB-Help: https://www.purebasic.com/documentation ... jects.html
- An object that is associated with an index is automatically freed when reusing that index.


