* xmlBufSetAllocationScheme: * @buf: the buffer to tune * @scheme: allocation scheme to use * * Sets the allocation scheme for this buffer * * returns 0 in case of success and -1 in case of failure */
| 238 | * returns 0 in case of success and -1 in case of failure |
| 239 | */ |
| 240 | int |
| 241 | xmlBufSetAllocationScheme(xmlBufPtr buf, |
| 242 | xmlBufferAllocationScheme scheme) { |
| 243 | if ((buf == NULL) || (buf->error != 0)) { |
| 244 | return(-1); |
| 245 | } |
| 246 | if (buf->alloc == XML_BUFFER_ALLOC_IO) |
| 247 | return(-1); |
| 248 | if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) || |
| 249 | (scheme == XML_BUFFER_ALLOC_EXACT) || |
| 250 | (scheme == XML_BUFFER_ALLOC_HYBRID) || |
| 251 | (scheme == XML_BUFFER_ALLOC_BOUNDED)) { |
| 252 | buf->alloc = scheme; |
| 253 | if (buf->buffer) |
| 254 | buf->buffer->alloc = scheme; |
| 255 | return(0); |
| 256 | } |
| 257 | /* |
| 258 | * Switching a buffer ALLOC_IO has the side effect of initializing |
| 259 | * the contentIO field with the current content |
| 260 | */ |
| 261 | if (scheme == XML_BUFFER_ALLOC_IO) { |
| 262 | buf->alloc = XML_BUFFER_ALLOC_IO; |
| 263 | buf->contentIO = buf->content; |
| 264 | } |
| 265 | return(-1); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * xmlBufFree: |
no outgoing calls
no test coverage detected