RFC-24 macros question

Daniel Morissette dmorissette at MAPGEARS.COM
Mon Jul 9 16:03:56 EDT 2007


Umberto,

As part of your work on RFC-24 you defined the following two macros:

#define MS_REFCNT_IS_NOT_ZERO(obj) (MS_REFCNT_DECR(obj))>0
#define MS_REFCNT_IS_ZERO(obj) (MS_REFCNT_DECR(obj))<=0

I find the name of the macros confusing when we encounter them in if 
statements in the code because it is not obvious that they include an 
implicit decrement of the refcount. At first I thought the code calling 
them was just testing whether refcount was zero but I didn't realize 
until I looked at the macros that they also decremented it.

Would it not be better if the macros were named in a way that made it 
clear that they will also decrement refcount, perhaps:

#define MS_REFCNT_DECR_NOT_ZERO(obj) (MS_REFCNT_DECR(obj))>0
#define MS_REFCNT_DECR_ZERO(obj) (MS_REFCNT_DECR(obj))<=0

What do you think?

Daniel
-- 
Daniel Morissette
http://www.mapgears.com/



More information about the mapserver-dev mailing list