C (104/274)

From:Allan Odgaard
Date:13 Sep 2000 at 22:44:12
Subject:Re: Input Handlers using StormC and MUI

On 13-Sep-00, Allen Kong wrote:

> ULONG Time_New (struct IClass *Class, Object *obj, Msg msg)
> {
> TimeData *Data;

> ULONG Result = DoSuperMethodA(Class,obj,msg);
> if(!Result)
> return 0;

The result is the actual object created. The 'obj' pointer given to your
function is invalid until you call the superclass.

> if(Data)

This check is redundant -- if the object has been created, instance data
have also been allocated.

> return !Result;

You must return the object, i.e. the result from your DoSuperMethod()

> CoerceMethod(Class,obj,OM_DISPOSE);

This must only be called if your code fails, but the superclass didn't.
In your code it'd also be called if the superclass failed.

I took the liberty to rewrite your code, and also added correct resource
disposal ;-)

Regards Allan