How to pass data in malloc array of one class to another class
-
Currently I am emitting the pointer to malloc array in a signal of class A. That signal is connected to SLOT of class B where the pointer is successfully received.
If i am deleting the pointer in ClassB, the data is not getting deleted. Which is leading to memory leak. -
@prashant.qt.developer said in How to pass data in malloc array of one class to another class:
malloc array
What is that?
Do you really use malloc() in a C++ application?!
Use "new" instead."If i am deleting the pointer in ClassB, the data is not getting deleted" - please show your code.
-
@prashant.qt.developer said in How to pass data in malloc array of one class to another class:
If i am deleting the pointer in ClassB, the data is not getting deleted. Which is leading to memory leak.
how are the slot AND the pointer-parameter declared? Please show EXACT declarations.
and...do you malloc the space or is it being allocated by a third party library that simply returns its address to you?
-
@prashant.qt.developer
if You allocate memory with malloc, calloc or realloc you can't delete this memory. use free() to free the allocated Memory!