30#define SIZE_MAX ((size_t) -1)
33#define WITH_BUFFER_COMPAT
47 xmlBufferAllocationScheme
alloc;
55#ifdef WITH_BUFFER_COMPAT
60#define UPDATE_COMPAT(buf) \
61 if (buf->size < INT_MAX) buf->compat_size = buf->size; \
62 else buf->compat_size = INT_MAX; \
63 if (buf->use < INT_MAX) buf->compat_use = buf->use; \
64 else buf->compat_use = INT_MAX;
71#define CHECK_COMPAT(buf) \
72 if (buf->size != (size_t) buf->compat_size) \
73 if (buf->compat_size < INT_MAX) \
74 buf->size = buf->compat_size; \
75 if (buf->use != (size_t) buf->compat_use) \
76 if (buf->compat_use < INT_MAX) \
77 buf->use = buf->compat_use;
80#define UPDATE_COMPAT(buf)
81#define CHECK_COMPAT(buf)
95 if ((
buf) && (
buf->error == 0))
110 if ((
buf) && (
buf->error == 0))
242 xmlBufferAllocationScheme
scheme) {
246 if (
buf->alloc == XML_BUFFER_ALLOC_IO)
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)) {
261 if (
scheme == XML_BUFFER_ALLOC_IO) {
262 buf->alloc = XML_BUFFER_ALLOC_IO;
263 buf->contentIO =
buf->content;
281 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) &&
284 }
else if (
buf->content !=
NULL) {
298 if ((
buf ==
NULL) || (
buf->error != 0))
return;
299 if (
buf->content ==
NULL)
return;
302 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) &&
304 size_t start_buf =
buf->content -
buf->contentIO;
306 buf->size += start_buf;
307 buf->content =
buf->contentIO;
329 if ((
buf ==
NULL) || (
buf->error != 0))
return(0);
331 if (
len == 0)
return(0);
332 if (
len >
buf->use)
return(0);
335 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) && (
buf->contentIO !=
NULL)) {
347 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) && (
buf->contentIO !=
NULL)) {
348 size_t start_buf =
buf->content -
buf->contentIO;
349 if (start_buf >=
buf->size) {
351 buf->content =
buf->contentIO;
352 buf->content[
buf->use] = 0;
353 buf->size += start_buf;
358 buf->content[
buf->use] = 0;
380 if ((
buf ==
NULL) || (
buf->error != 0))
return(0);
383 if (len < buf->
size -
buf->use)
384 return(
buf->size -
buf->use - 1);
390 if (
buf->size > (
size_t)
len) {
397 if (
buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
409 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) && (
buf->contentIO !=
NULL)) {
410 size_t start_buf =
buf->content -
buf->contentIO;
413 if (newbuf ==
NULL) {
417 buf->contentIO = newbuf;
418 buf->content = newbuf + start_buf;
421 if (newbuf ==
NULL) {
425 buf->content = newbuf;
429 return(
buf->size -
buf->use - 1);
492 if ((!
buf) || (
buf->error))
495 return(
buf->content);
510 if ((!
buf) || (
buf->error))
514 return(&
buf->content[
buf->use]);
536 buf->content[
buf->use] = 0;
553 if ((!
buf) || (
buf->error))
572 if ((!
buf) || (
buf->error))
594 if ((!
buf) || (
buf->error))
598 return((
buf->size >
buf->use) ? (
buf->size -
buf->use - 1) : 0);
612 if ((!
buf) || (
buf->error))
616 return(
buf->use == 0);
639 if (
buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
650 if (size < buf->
size)
655 case XML_BUFFER_ALLOC_IO:
656 case XML_BUFFER_ALLOC_DOUBLEIT:
658 if (
buf->size == 0) {
663 while (
size > newSize) {
671 case XML_BUFFER_ALLOC_EXACT:
674 case XML_BUFFER_ALLOC_HYBRID:
675 if (
buf->use < BASE_BUFFER_SIZE)
679 while (
size > newSize) {
694 if ((
buf->alloc == XML_BUFFER_ALLOC_IO) && (
buf->contentIO !=
NULL)) {
695 start_buf =
buf->content -
buf->contentIO;
697 if (start_buf > newSize) {
700 buf->content =
buf->contentIO;
701 buf->content[
buf->use] = 0;
702 buf->size += start_buf;
709 buf->contentIO = rebuf;
710 buf->content = rebuf + start_buf;
718 }
else if (
buf->size -
buf->use < 100) {
737 buf->content = rebuf;
768 if (
len == 0)
return 0;
773 if (
len < 0)
return -1;
774 if (
len == 0)
return 0;
777 if ((
size_t)
len >=
buf->size -
buf->use) {
782 needSize =
buf->use +
len + 1;
783 if (
buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
800 buf->content[
buf->use] = 0;
977 ret->content =
buf->content;
978 ret->contentIO =
buf->contentIO;
size_t xmlBufAvail(const xmlBufPtr buf)
int xmlBufAddLen(xmlBufPtr buf, size_t len)
void xmlBufEmpty(xmlBufPtr buf)
static size_t xmlBufGrowInternal(xmlBufPtr buf, size_t len)
xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer)
int xmlBufGetAllocationScheme(xmlBufPtr buf)
int xmlBufResize(xmlBufPtr buf, size_t size)
xmlChar * xmlBufEnd(xmlBufPtr buf)
size_t xmlBufLength(const xmlBufPtr buf)
static void xmlBufOverflowError(xmlBufPtr buf, const char *extra)
#define UPDATE_COMPAT(buf)
int xmlBufIsEmpty(const xmlBufPtr buf)
void xmlBufFree(xmlBufPtr buf)
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
xmlChar * xmlBufDetach(xmlBufPtr buf)
xmlBufPtr xmlBufCreateSize(size_t size)
xmlBufPtr xmlBufCreate(void)
int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer)
xmlChar * xmlBufContent(const xmlBuf *buf)
int xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme)
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string)
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf)
size_t xmlBufDump(FILE *file, xmlBufPtr buf)
size_t xmlBufUse(const xmlBufPtr buf)
#define CHECK_COMPAT(buf)
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len)
int xmlBufGrow(xmlBufPtr buf, int len)
static void xmlBufMemoryError(xmlBufPtr buf, const char *extra)
int xmlBufCat(xmlBufPtr buf, const xmlChar *str)
int xmlBufCCat(xmlBufPtr buf, const char *str)
int xmlBufUpdateInput(xmlBufPtr buf, xmlParserInputPtr input, size_t pos)
size_t xmlBufShrink(xmlBufPtr buf, size_t len)
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
#define XML_MAX_TEXT_LENGTH
xmlReallocFunc xmlRealloc
xmlMallocFunc xmlMallocAtomic
xmlBufferAllocationScheme xmlBufferAllocScheme
XML_HIDDEN void XML_HIDDEN void __xmlSimpleError(int domain, int code, struct _xmlNode *node, const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4
xmlBufferAllocationScheme alloc
XMLPUBFUN int xmlStrlen(const xmlChar *str)
XMLPUBFUN const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val)