I am writing a custom edit control(C++/Win32) and have already gotten the basic functionality up an running.
- I use a c-style buffer to store the contents of the visible text in the edit control. Now, I was wondering if I should use
malloc/free
combo to allocate memory from the heap, or should I go on using thenew/delete
pair? I encountered a problem the other day. I created a dynamically
allocated c -style string class member(char* szClassName
). Then I
initialized it in an initializer list as
szClassName("name of class")
.When I used 'delete szClassName' in my destructor, it lead to some memory allocation error. Coould you guys tell me the problem
here?
Finally, could you guys give me some tips on memory management that you found useful in your own programming ventures?
Thanks,
Devjeet!