| 139 | } |
| 140 | |
| 141 | static int addResult(resultCacheObj *cache, shapeObj *shape) |
| 142 | { |
| 143 | int i; |
| 144 | |
| 145 | if(cache->numresults == cache->cachesize) { /* just add it to the end */ |
| 146 | if(cache->cachesize == 0) |
| 147 | cache->results = (resultObj *) malloc(sizeof(resultObj)*MS_RESULTCACHEINCREMENT); |
| 148 | else |
| 149 | cache->results = (resultObj *) realloc(cache->results, sizeof(resultObj)*(cache->cachesize+MS_RESULTCACHEINCREMENT)); |
| 150 | if(!cache->results) { |
| 151 | msSetError(MS_MEMERR, "Realloc() error.", "addResult()"); |
| 152 | return(MS_FAILURE); |
| 153 | } |
| 154 | cache->cachesize += MS_RESULTCACHEINCREMENT; |
| 155 | } |
| 156 | |
| 157 | i = cache->numresults; |
| 158 | |
| 159 | cache->results[i].classindex = shape->classindex; |
| 160 | cache->results[i].tileindex = shape->tileindex; |
| 161 | cache->results[i].shapeindex = shape->index; |
| 162 | cache->results[i].resultindex = shape->resultindex; |
| 163 | cache->numresults++; |
| 164 | |
| 165 | if(cache->numresults == 1) |
| 166 | cache->bounds = shape->bounds; |
| 167 | else |
| 168 | msMergeRect(&(cache->bounds), &(shape->bounds)); |
| 169 | |
| 170 | return(MS_SUCCESS); |
| 171 | } |
| 172 | |
| 173 | /* |
| 174 | ** Serialize a query result set to disk. |
no test coverage detected