Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to pass data in malloc array of one class to another class
Forum Updated to NodeBB v4.3 + New Features

How to pass data in malloc array of one class to another class

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 418 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prashant.qt.developer
    wrote on last edited by
    #1

    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.

    jsulmJ GerhardG 2 Replies Last reply
    0
    • P prashant.qt.developer

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      7
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by Kent-Dorfman
        #3

        @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?

        1 Reply Last reply
        2
        • P prashant.qt.developer

          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.

          GerhardG Offline
          GerhardG Offline
          Gerhard
          wrote on last edited by
          #4

          @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!

          Gerhard

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved