[haiku-bugs] Re: [Haiku] #11934: [PATCH] Solve memory leaks in Deskbar and some replicants.

  • From: "pulkomandy" <trac@xxxxxxxxxxxx>
  • Date: Tue, 31 Mar 2015 11:53:21 -0000

#11934: [PATCH] Solve memory leaks in Deskbar and some replicants.
------------------------------+----------------------------
   Reporter:  Barrett         |      Owner:  stippi
       Type:  enhancement     |     Status:  new
   Priority:  normal          |  Milestone:  R1
  Component:  User Interface  |    Version:  R1/Development
 Resolution:                  |   Keywords:  Deskbar
 Blocked By:                  |   Blocking:
Has a Patch:  1               |   Platform:  All
------------------------------+----------------------------

Comment (by pulkomandy):

 Instead of using VLA arrays, you can use BStackOrHeapArray. The problem
 with VLAs is that you can get a stack overflow if the data is big enough,
 as they are allocated on the stack. BStackOrHeapArray will only allocate
 small enough data on the stack (you set the threshold as a template
 parameter), and will allocate extra memory if needed. It takes care of
 freeing it when it goes out of scope.

 Alternatively, a BAutoDeleter could be used (but in that case the data
 will never be on the stack).

--
Ticket URL: <https://dev.haiku-os.org/ticket/11934#comment:8>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: