Permalink
Browse files

rfc24 compliance

  • Loading branch information...
1 parent d059db3 commit 454ca2c1aa087415d3c271bfd769cf8691cbb209 @unicolet unicolet committed Jan 18, 2013
Showing with 17 additions and 9 deletions.
  1. +8 −4 mapoutput.c
  2. +1 −0 mapscript/swiginc/map.i
  3. +1 −4 mapscript/swiginc/outputformat.i
  4. +7 −1 mapserver.h
View
@@ -397,6 +397,10 @@ void msFreeOutputFormat( outputFormatObj *format )
{
if( format == NULL )
return;
+ if( MS_REFCNT_DECR_IS_NOT_ZERO(format) ) {
+ return;
+ }
+
if(MS_RENDERER_PLUGIN(format) && format->vtable) {
format->vtable->cleanup(MS_RENDERER_CACHE(format->vtable));
free( format->vtable );
@@ -479,7 +483,7 @@ int msAppendOutputFormat(mapObj *map, outputFormatObj *format)
sizeof(void*) * map->numoutputformats );
map->outputformatlist[map->numoutputformats-1] = format;
- format->refcount++;
+ MS_REFCNT_INCR(format);
}
return map->numoutputformats;
@@ -505,8 +509,8 @@ int msRemoveOutputFormat(mapObj *map, const char *name)
i = msGetOutputFormatIndex(map, name);
if (i >= 0) {
map->numoutputformats--;
- if( map->outputformatlist[i]->refcount-- < 1 )
- msFreeOutputFormat( map->outputformatlist[i] );
+ MS_REFCNT_DECR(map->outputformatlist[i]);
+ msFreeOutputFormat( map->outputformatlist[i] );
for (j=i; j<map->numoutputformats-1; j++) {
map->outputformatlist[j] = map->outputformatlist[j+1];
@@ -613,7 +617,7 @@ void msApplyOutputFormat( outputFormatObj **target,
assert( target != NULL );
- if( *target != NULL && --((*target)->refcount) < 1 ) {
+ if( *target != NULL && MS_REFCNT_DECR_IS_ZERO( (*target) ) ) {
formatToFree = *target;
*target = NULL;
}
@@ -188,6 +188,7 @@
%newobject getOutputFormat;
outputFormatObj *getOutputFormat(int i) {
if(i >= 0 && i < self->numoutputformats) {
+ MS_REFCNT_INCR(self->outputformatlist[i]);
return (self->outputformatlist[i]);
} else {
return NULL;
@@ -49,17 +49,14 @@
msInitializeRendererVTable(format);
- /* Else, continue */
- format->refcount++;
format->inmapfile = MS_TRUE;
return format;
}
~outputFormatObj()
{
- if ( --self->refcount < 1 )
- msFreeOutputFormat( self );
+ msFreeOutputFormat( self );
}
#ifndef SWIGJAVA
View
@@ -752,6 +752,13 @@ extern "C" {
/************************************************************************/
typedef struct {
+#ifdef SWIG
+ %immutable;
+#endif /* SWIG */
+ int refcount;
+#ifdef SWIG
+ %mutable;
+#endif /* SWIG */
char *name;
char *mimetype;
char *driver;
@@ -762,7 +769,6 @@ extern "C" {
int bands;
int numformatoptions;
char **formatoptions;
- int refcount;
int inmapfile; /* boolean value for writing */
#ifndef SWIG
rendererVTableObj *vtable;

0 comments on commit 454ca2c

Please sign in to comment.