Re: memory leak?




"Dani" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:uXXGN3c0HHA.5152@xxxxxxxxxxxxxxxxxxxxxxx

[...]
But do not assume that you have solved your problem, you should
investigate this memory leak deeply before you continue with writing your
program.

I completely agree.

Moreover, I wonder why the OP is using malloc/free (or even new/delete),
when he could instead use the more robust C++ container classes like
std::vector or MFC containers. If he wants to allocate an array of bytes to
store his video stream data, he could use std::vector<BYTE> or MFC container
CByteArray.

And, as Doug pointed in several of his previous posts in these newsgroups,
smart pointers like std::auto_ptr are good tools to fight against memory
leaks...

Moreover, frankly speaking, I don't like very much the use 'char' to
identify a 'byte'. IMHO, the code would be more readable and robust if an
explicit BYTE identifier is used, instead of 'char' (I don't know if the C++
standard states that a 'char' is an 8-bits byte... but I would always prefer
the explicit 'byte' specification instead of 'char'...).

Giovanni


.



Relevant Pages

  • Re: How to print a string of unsigned chars?
    ... have the same representation and alignment requirements as a pointer ... Although it isn't explicit, I'm sure that 'a' ... character type, and thus pointers to all three flavors of char must be ... and do not expect to encounter one. ...
    (comp.lang.c)
  • Re: Abstraction layer between C and CPU
    ... It is also clear that one should establish a context, ... > A char may at least be a byte or higher. ... I'll let you decide if this is explicit or not: ... The values given below shall be replaced by constant expressions ...
    (comp.lang.c)
  • Re: Run VBS on a Remote?
    ... a .vbs file - when automating a process you should always be explicit ... and invoke the underlying executable in order to make it robust: ... psexec \\MyDesktopsName cscript.exe //nologo ...
    (microsoft.public.windowsxp.general)
  • Re: trim function dumping core
    ... char *trim ... Hell's teeth, man, can't you be more explicit? ... were the compiler messages? ...
    (comp.lang.c)
  • Re: No need to optimize in assembly anymore
    ... I am criticizing the *universal* use of container classes. ... sprintf(buf, "%s%s", path, filename); ... deletebuf; ... char buf; ...
    (comp.lang.asm.x86)