I propose that the CImage class be modified to do its reference
counting implicitly.

The reason for this is that the new/delete semantics of the current
scheme are confusing, and it is not hard to leak memory by forgetting
to Release(), or cause segfaults by deleting an object that was
already Release()'d.

Perhaps the simplest way to implement this is to create a DImage
class (ideally with a better name):

class DImage {
protected:
        CImage * img;
public:
        DImage () { img = new CImage (); }
        DImage (DImage const & foo) { foo.img->AddRef(); img = foo.img; }
        ~DImage () { img->Release() }
        Release () {}
};

If you add in all the CImage functions so they operate on the
underlying data (does operator() do that?), DImage will behave
exactly like CImage, except that Release() is now optional.

CImage will continue to work as before for legacy code.

When avifile goes to its next major version, the underlying
CImage class can become non-public and be stripped down to just the
reference-counted data.

If you think this is reasonable, I will happily implement it and send
you a patch.

-Eric

_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile

Reply via email to