简体   繁体   中英

Memory leak in Program to Rotate an image

I am new to c++ programming, I have written a program to rotate an image. The input for image is in ppm format. I am having a memory leak in my main function or the rotate function with below signature:

     <vector> rotate(picture);

I have tried to debug a lot using valgrind but was unable to catch the issue, here is the simplified, executable version of the code: http://ideone.com/vHjv

could anyone please help me out with this, thank you

Note : The code may seem long, the leak is at the end of the rotate() function or main(). I don't know what is causing the leak.

In the function myMemCpy you forgot to deallocate temp . There is a function for copying an array in the standard library. It's named quite aptly: std::copy . I suggest that you use it instead of your leaky version. To further reduce your risk of leaks, use std::vector instead of pointers to raw arrays.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM