On 9/24/2015 4:00 PM, jacobnavia wrote:
> Le 24/09/2015 21:15, Christopher Pisz a écrit :
>
>> Consult the documentationfor CForwardBlock, whatever that is.
>
> That's very easily done. Thanks. No documentation.
>
>> It looks like some MFC-esk poopy written by someone who has no notion of
>> RAII.
>>
> Maybe, if you say so, I would agree if I knew what "MFC-esk" could mean
> in a Unix environment with gcc as compiler...
I mean naming classes "C<somename>" as if the prefix of C does something
special for it. CFile, CSocket, CSnuffleupogus, etc. They also love
manual reference counting that makes bugs. Maybe the practice came from
somewhere else before MFC, I dunno, but it is silly. You'll also see
increment this and decrement that all over the place, usually without
concern for what situations it will actually increment to decrement
correctly...which brings us to RAII. Write a test in your compiler where
you create something that is a CFowardBlock and throw an exception after
you create it. Put a breakpoint on the call that frees the buffer. Did
it get freed or did it leak?
>
>> The error is coming from some part of CFowardBlock that you left out. It
>> probably has a pure virtual function and was made to be derived from.
>>
>
> It has many virtual functions, yes.
>
>> Why in the world you need a seperate init and freeit method is not
>> apparent. Why not allocate in the constructor and release in the
>> deconstructor? This class will leak as is, if an exception is thrown.
>>
>
> Yes, I thought C++ would use that but the people that wrote that didn't.
> I can't tell you their reasons, and your reasons look reasonable at
> first sight. But first sights do not count here. Maybe there was a
> reason, I do not know.
>
>> You also didn't show what m_disk_pool's type is or what it's get method
>> returns.
>>
>>
>
> It is a Fifo template,
>
> template<class T, class P, int LenLn2>
> class FifoBase
>
> and one of the template's method is
>
> ...
> T *Get();
>
>
> Mmmmm that brings us not a lot more near the solution but...
>