* appendBinaryStringInfo * * Append arbitrary binary data to a StringInfo, allocating more space * if necessary. Ensures that a trailing null byte is present. */
| 240 | * if necessary. Ensures that a trailing null byte is present. |
| 241 | */ |
| 242 | void |
| 243 | appendBinaryStringInfo(StringInfo str, const char *data, int datalen) |
| 244 | { |
| 245 | Assert(str != NULL); |
| 246 | |
| 247 | /* Make more room if needed */ |
| 248 | enlargeStringInfo(str, datalen); |
| 249 | |
| 250 | /* OK, append the data */ |
| 251 | memcpy(str->data + str->len, data, datalen); |
| 252 | str->len += datalen; |
| 253 | |
| 254 | /* |
| 255 | * Keep a trailing null in place, even though it's probably useless for |
| 256 | * binary data. (Some callers are dealing with text but call this because |
| 257 | * their input isn't null-terminated.) |
| 258 | */ |
| 259 | str->data[str->len] = '\0'; |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | * appendBinaryStringInfoNT |