[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] out of memory
From:       Ingo =?iso-8859-1?q?Kl=F6cker?= <kloecker () kde ! org>
Date:       2005-05-26 15:31:21
Message-ID: 200505261731.22644 () erwin ! ingo-kloecker ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Thursday 26 May 2005 16:31, Mark Bucciarelli wrote:
> David Faure wrote:
> >On Thursday 26 May 2005 15:32, Mark Bucciarelli wrote:
> >>In C, I'm used to checking that malloc returns a non-null pointer
> >> to make sure you app is not out of memory.
> >>
> >>How do you do this in C++?
> >
> >This was discussed some time ago, and the consenssus was that in KDE
> > code, we don't check for out of memory, and we don't need to.
>
> Makes sense.  Because of how the OS' work, checking the rval of
> malloc doesn't even seem useful.
>
> Follow up question---is there similar consensus on error handling?
>
> I'm working on dcop iface and I am falling back to my C ways of
> having methods return an integer--0 for success, positive integer for
> error; e.g.,
>
> #!/bin sh
> RVAL=`dcop karm-123 dcopiface booktime libkcal-uid 20050505T1050 360`
> if [ "$RVAL" -gt "0" ]
> then
>   echo `dcop karm-123 dcopiface geterror $RVAL`
>   exit $RVAL
> fi
>
> It's nice b/c if you use this consistently, then you can bubble up
> all kinds of errors, add more detail later as the library grows and
> morphs: invalid resource, lock failed, async resource currently
> locked, bad task UID, confused resource manager, etc.
>
> But most libkcal fcn's seem to simply return a true or false, and
> give little info on the specific error.  (I did see one use of
> kdError (sp?)).
>
> So, is this approach (non-boolean rvals) also considered a waste of
> time?

I don't think it's a waste of time. In fact we use int return values in 
some dcop calls of kmail which are used by kmailcvt for importing 
messages and obviously this makes it possible to show meaningful error 
messages in kmailcvt.

Regards,
Ingo

[Attachment #5 (application/pgp-signature)]

_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic