* xmlBufferCreateSize: * @size: initial size of buffer * * routine to create an XML buffer. * returns the new structure. */
| 7135 | * returns the new structure. |
| 7136 | */ |
| 7137 | xmlBufferPtr |
| 7138 | xmlBufferCreateSize(size_t size) { |
| 7139 | xmlBufferPtr ret; |
| 7140 | |
| 7141 | if (size >= UINT_MAX) |
| 7142 | return(NULL); |
| 7143 | ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); |
| 7144 | if (ret == NULL) |
| 7145 | return(NULL); |
| 7146 | ret->use = 0; |
| 7147 | ret->alloc = xmlBufferAllocScheme; |
| 7148 | ret->size = (size ? size + 1 : 0); /* +1 for ending null */ |
| 7149 | if (ret->size){ |
| 7150 | ret->content = (xmlChar *) xmlMallocAtomic(ret->size); |
| 7151 | if (ret->content == NULL) { |
| 7152 | xmlFree(ret); |
| 7153 | return(NULL); |
| 7154 | } |
| 7155 | ret->content[0] = 0; |
| 7156 | } else |
| 7157 | ret->content = NULL; |
| 7158 | ret->contentIO = NULL; |
| 7159 | return(ret); |
| 7160 | } |
| 7161 | |
| 7162 | /** |
| 7163 | * xmlBufferDetach: |
no outgoing calls