heap->stack

Hi,
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.

pisselouAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grg99Commented:
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?



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

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.