| 186 | } |
| 187 | |
| 188 | static ISC_STATUS merge_setup(const ClumpletReader& input, UCHAR** out, const UCHAR* const end, |
| 189 | FB_SIZE_T delta_length) |
| 190 | { |
| 191 | /************************************** |
| 192 | * |
| 193 | * m e r g e _ s e t u p |
| 194 | * |
| 195 | ************************************** |
| 196 | * |
| 197 | * Functional description |
| 198 | * Get ready to toss new stuff onto an info packet. This involves |
| 199 | * picking up and bumping the "count" field and copying what is |
| 200 | * already there. |
| 201 | * |
| 202 | **************************************/ |
| 203 | FB_SIZE_T length = input.getClumpLength(); |
| 204 | const FB_SIZE_T new_length = length + delta_length; |
| 205 | |
| 206 | if (new_length > MAX_USHORT || *out + new_length + 2 >= end) |
| 207 | { |
| 208 | (*out)[-1] = isc_info_truncated; |
| 209 | return FB_FAILURE; |
| 210 | } |
| 211 | |
| 212 | const USHORT count = 1 + *(input.getBytes()); |
| 213 | PUT_WORD(*out, new_length); |
| 214 | PUT(*out, (UCHAR) count); |
| 215 | |
| 216 | // Copy data portion of information sans original count |
| 217 | |
| 218 | if (--length) |
| 219 | { |
| 220 | memcpy(*out, input.getBytes() + 1, length); |
| 221 | *out += length; |
| 222 | } |
| 223 | |
| 224 | return FB_SUCCESS; |
| 225 | } |
no test coverage detected