| 75 | /************************************************************************/ |
| 76 | |
| 77 | void msFreeMap(mapObj *map) { |
| 78 | int i; |
| 79 | |
| 80 | if(!map) return; |
| 81 | |
| 82 | /* printf("msFreeMap(): maybe freeing map at %p count=%d.\n",map, map->refcount); */ |
| 83 | if(MS_REFCNT_DECR_IS_NOT_ZERO(map)) { return; } |
| 84 | if(map->debug >= MS_DEBUGLEVEL_VV) |
| 85 | msDebug("msFreeMap(): freeing map at %p.\n",map); |
| 86 | |
| 87 | msCloseConnections(map); |
| 88 | |
| 89 | msFree(map->name); |
| 90 | msFree(map->shapepath); |
| 91 | msFree(map->mappath); |
| 92 | |
| 93 | msFreeProjection(&(map->projection)); |
| 94 | msFreeProjection(&(map->latlon)); |
| 95 | |
| 96 | msFreeLabelCache(&(map->labelcache)); |
| 97 | |
| 98 | msFree(map->imagetype); |
| 99 | |
| 100 | msFreeFontSet(&(map->fontset)); |
| 101 | |
| 102 | msFreeSymbolSet(&map->symbolset); /* free symbols */ |
| 103 | msFree(map->symbolset.filename); |
| 104 | |
| 105 | freeWeb(&(map->web)); |
| 106 | |
| 107 | freeScalebar(&(map->scalebar)); |
| 108 | freeReferenceMap(&(map->reference)); |
| 109 | freeLegend(&(map->legend)); |
| 110 | |
| 111 | for(i=0; i<map->maxlayers; i++) { |
| 112 | if(GET_LAYER(map, i) != NULL) { |
| 113 | GET_LAYER(map, i)->map = NULL; |
| 114 | if(freeLayer((GET_LAYER(map, i))) == MS_SUCCESS) |
| 115 | free(GET_LAYER(map, i)); |
| 116 | } |
| 117 | } |
| 118 | msFree(map->layers); |
| 119 | |
| 120 | if(map->layerorder) |
| 121 | free(map->layerorder); |
| 122 | |
| 123 | msFree(map->templatepattern); |
| 124 | msFree(map->datapattern); |
| 125 | msFreeHashItems(&(map->configoptions)); |
| 126 | if(map->outputformat && map->outputformat->refcount > 0 && --map->outputformat->refcount < 1) |
| 127 | msFreeOutputFormat(map->outputformat); |
| 128 | |
| 129 | for(i=0; i<map->numoutputformats; i++ ) { |
| 130 | if(map->outputformatlist[i]->refcount > 0 && --map->outputformatlist[i]->refcount < 1) |
| 131 | msFreeOutputFormat(map->outputformatlist[i]); |
| 132 | } |
| 133 | if(map->outputformatlist != NULL) |
| 134 | msFree(map->outputformatlist); |