* xmlBufCreateSize: * @size: initial size of buffer * * routine to create an XML buffer. * returns the new structure. */
| 147 | * returns the new structure. |
| 148 | */ |
| 149 | xmlBufPtr |
| 150 | xmlBufCreateSize(size_t size) { |
| 151 | xmlBufPtr ret; |
| 152 | |
| 153 | if (size == SIZE_MAX) |
| 154 | return(NULL); |
| 155 | ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf)); |
| 156 | if (ret == NULL) |
| 157 | return(NULL); |
| 158 | ret->use = 0; |
| 159 | ret->error = 0; |
| 160 | ret->buffer = NULL; |
| 161 | ret->alloc = xmlBufferAllocScheme; |
| 162 | ret->size = (size ? size + 1 : 0); /* +1 for ending null */ |
| 163 | UPDATE_COMPAT(ret); |
| 164 | if (ret->size){ |
| 165 | ret->content = (xmlChar *) xmlMallocAtomic(ret->size); |
| 166 | if (ret->content == NULL) { |
| 167 | xmlFree(ret); |
| 168 | return(NULL); |
| 169 | } |
| 170 | ret->content[0] = 0; |
| 171 | } else |
| 172 | ret->content = NULL; |
| 173 | ret->contentIO = NULL; |
| 174 | return(ret); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * xmlBufDetach: |
no outgoing calls
no test coverage detected