• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:


How should you change this heap-allocation-code to stack-allocation-code ??
      textel->length = 15* sizeof(int16);
      textel->buffer = new int16[textel->length];
Thanks in advance.

1 Solution
about the closest you can get is to define:

int16 buffer[15];

as part of the struct.  But it's still probably heap-based, as the struct seems to be accessed by a pointer, most likely created thru a malloc(), although it could be a pointer to static or stack struct too.

Perhaps we coul dhelp more if you'd tell us exactl;y what you're trying to do, and why, and where textel comes from, and is textel static or dynamically allocated, one or multiple times?

pisselouAuthor Commented:
Hi, I got code which worked, but when I looked with the task manager I clearly had a memory leak (memory raised till it crashed). Now it works fine, and
1) without memory leak
2) I don't have to think about placing the delete
3)maybe faster, since it's on the stack

So, thanks a lot.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now