[geos-devel] Issue with returning Coordinate * rather than value

Martin Davis mbdavis at VividSolutions.com
Fri Nov 15 12:58:49 EST 2002


I think we should assume the caller is competent.  Don't forget, the primary purpose of CoordinateList is to support GEOS algorithms, which we can assume to have been designed by a brilliant programmer who never makes mistakes.  8^)

Martin Davis, Senior Technical Specialist
Vivid Solutions Inc.
Suite #1A-2328 Government Street   Victoria, B.C.   V8T 5G5
Phone: (250) 385 6040    Fax: (250) 385 6046
EMail: mbdavis at vividsolutions.com  Web: www.vividsolutions.com


> -----Original Message-----
> From: Norman Vine [mailto:nhv at cape.com]
> Sent: Friday, November 15, 2002 9:56 AM
> To: geos-devel at geos.refractions.net
> Subject: Re: [geos-devel] Issue with returning Coordinate * 
> rather than
> value
> 
> 
> David Blasby writes:
> 
> > > Coordinate *getAt(int i)  /// Safe
> > > Coordinate *[int i]   /// DANGER !!!! super fast RAW access
> > 
> > Yes - I like that. The getAt(int) should return a 
> non-pointer or its should allocate a new
> > Cooridinate and return that.
> > 
> > Is the [int] method going to do range checking or are we 
> just going to assume the caller is
> > competent?
> 
> Good question :-)
> 
> I usually just have it  return the underlying vector<> [] operator
> if you want SAFE access DON'T use it !!
> 
> Norman
> 
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 




More information about the geos-devel mailing list