** Ensure there is at least one free entry in the layers and layerorder ** arrays of this mapObj. Grow the allocated layers/layerorder arrays if ** necessary and allocate a new layer for layers[numlayers] if there is ** not already one, setting its contents to all zero bytes (i.e. does not ** call initLayer() on it). ** ** This function is safe to use for the initial allocation of the layers[]
| 5117 | ** Returns a reference to the new layerObj on success, NULL on error. |
| 5118 | */ |
| 5119 | layerObj *msGrowMapLayers( mapObj *map ) |
| 5120 | { |
| 5121 | /* Do we need to increase the size of layers/layerorder by |
| 5122 | * MS_LAYER_ALLOCSIZE? |
| 5123 | */ |
| 5124 | if (map->numlayers == map->maxlayers) { |
| 5125 | layerObj **newLayersPtr; |
| 5126 | int *newLayerorderPtr; |
| 5127 | int i, newsize; |
| 5128 | |
| 5129 | newsize = map->maxlayers + MS_LAYER_ALLOCSIZE; |
| 5130 | |
| 5131 | /* Alloc/realloc layers */ |
| 5132 | newLayersPtr = (layerObj**)realloc(map->layers, |
| 5133 | newsize*sizeof(layerObj*)); |
| 5134 | MS_CHECK_ALLOC(newLayersPtr, newsize*sizeof(layerObj*), NULL); |
| 5135 | |
| 5136 | map->layers = newLayersPtr; |
| 5137 | |
| 5138 | /* Alloc/realloc layerorder */ |
| 5139 | newLayerorderPtr = (int *)realloc(map->layerorder, |
| 5140 | newsize*sizeof(int)); |
| 5141 | MS_CHECK_ALLOC(newLayerorderPtr, newsize*sizeof(int), NULL); |
| 5142 | |
| 5143 | map->layerorder = newLayerorderPtr; |
| 5144 | |
| 5145 | map->maxlayers = newsize; |
| 5146 | for(i=map->numlayers; i<map->maxlayers; i++) { |
| 5147 | map->layers[i] = NULL; |
| 5148 | map->layerorder[i] = 0; |
| 5149 | } |
| 5150 | } |
| 5151 | |
| 5152 | if (map->layers[map->numlayers]==NULL) { |
| 5153 | map->layers[map->numlayers]=(layerObj*)calloc(1,sizeof(layerObj)); |
| 5154 | MS_CHECK_ALLOC(map->layers[map->numlayers], sizeof(layerObj), NULL); |
| 5155 | } |
| 5156 | |
| 5157 | return map->layers[map->numlayers]; |
| 5158 | } |
| 5159 | |
| 5160 | |
| 5161 | int msFreeLabelCacheSlot(labelCacheSlotObj *cacheslot) { |
no outgoing calls
no test coverage detected