ReactOS 0.4.16-dev-297-gc569aee
buf.c
Go to the documentation of this file.
1/*
2 * buf.c: memory buffers for libxml2
3 *
4 * new buffer structures and entry points to simplify the maintenance
5 * of libxml2 and ensure we keep good control over memory allocations
6 * and stay 64 bits clean.
7 * The new entry point use the xmlBufPtr opaque structure and
8 * xmlBuf...() counterparts to the old xmlBuf...() functions
9 *
10 * See Copyright for the status of this software.
11 *
12 * daniel@veillard.com
13 */
14
15#define IN_LIBXML
16#include "libxml.h"
17
18#include <string.h> /* for memset() only ! */
19#include <limits.h>
20#include <ctype.h>
21#include <stdlib.h>
22
23#include <libxml/tree.h>
24#include <libxml/globals.h>
25#include <libxml/tree.h>
26#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
27#include "buf.h"
28
29#ifndef SIZE_MAX
30#define SIZE_MAX ((size_t) -1)
31#endif
32
33#define WITH_BUFFER_COMPAT
34
43struct _xmlBuf {
44 xmlChar *content; /* The buffer content UTF8 */
45 unsigned int compat_use; /* for binary compatibility */
46 unsigned int compat_size; /* for binary compatibility */
47 xmlBufferAllocationScheme alloc; /* The realloc method */
48 xmlChar *contentIO; /* in IO mode we may have a different base */
49 size_t use; /* The buffer size used */
50 size_t size; /* The buffer size */
51 xmlBufferPtr buffer; /* wrapper for an old buffer */
52 int error; /* an error code if a failure occurred */
53};
54
55#ifdef WITH_BUFFER_COMPAT
56/*
57 * Macro for compatibility with xmlBuffer to be used after an xmlBuf
58 * is updated. This makes sure the compat fields are updated too.
59 */
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;
65
66/*
67 * Macro for compatibility with xmlBuffer to be used in all the xmlBuf
68 * entry points, it checks that the compat fields have not been modified
69 * by direct call to xmlBuffer function from code compiled before 2.9.0 .
70 */
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;
78
79#else /* ! WITH_BUFFER_COMPAT */
80#define UPDATE_COMPAT(buf)
81#define CHECK_COMPAT(buf)
82#endif /* WITH_BUFFER_COMPAT */
83
91static void
93{
94 __xmlSimpleError(XML_FROM_BUFFER, XML_ERR_NO_MEMORY, NULL, NULL, extra);
95 if ((buf) && (buf->error == 0))
96 buf->error = XML_ERR_NO_MEMORY;
97}
98
106static void
108{
109 __xmlSimpleError(XML_FROM_BUFFER, XML_BUF_OVERFLOW, NULL, NULL, extra);
110 if ((buf) && (buf->error == 0))
111 buf->error = XML_BUF_OVERFLOW;
112}
113
114
124
125 ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
126 if (ret == NULL) {
127 xmlBufMemoryError(NULL, "creating buffer");
128 return(NULL);
129 }
130 ret->use = 0;
131 ret->error = 0;
132 ret->buffer = NULL;
135 ret->alloc = xmlBufferAllocScheme;
136 ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
137 if (ret->content == NULL) {
138 xmlBufMemoryError(ret, "creating buffer");
139 xmlFree(ret);
140 return(NULL);
141 }
142 ret->content[0] = 0;
143 ret->contentIO = NULL;
144 return(ret);
145}
146
157
158 if (size == SIZE_MAX)
159 return(NULL);
160 ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
161 if (ret == NULL) {
162 xmlBufMemoryError(NULL, "creating buffer");
163 return(NULL);
164 }
165 ret->use = 0;
166 ret->error = 0;
167 ret->buffer = NULL;
168 ret->alloc = xmlBufferAllocScheme;
169 ret->size = (size ? size + 1 : 0); /* +1 for ending null */
171 if (ret->size){
172 ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
173 if (ret->content == NULL) {
174 xmlBufMemoryError(ret, "creating buffer");
175 xmlFree(ret);
176 return(NULL);
177 }
178 ret->content[0] = 0;
179 } else
180 ret->content = NULL;
181 ret->contentIO = NULL;
182 return(ret);
183}
184
195xmlChar *
197 xmlChar *ret;
198
199 if (buf == NULL)
200 return(NULL);
201 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
202 return(NULL);
203 if (buf->buffer != NULL)
204 return(NULL);
205 if (buf->error)
206 return(NULL);
207
208 ret = buf->content;
209 buf->content = NULL;
210 buf->size = 0;
211 buf->use = 0;
213
214 return ret;
215}
216
217
232
233 if (mem == NULL)
234 return(NULL);
235
236 ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
237 if (ret == NULL) {
238 xmlBufMemoryError(NULL, "creating buffer");
239 return(NULL);
240 }
241 ret->use = size;
242 ret->size = size;
245 ret->content = (xmlChar *) mem;
246 ret->error = 0;
247 ret->buffer = NULL;
248 return(ret);
249}
250
259int
261 if (buf == NULL) {
262#ifdef DEBUG_BUFFER
264 "xmlBufGetAllocationScheme: buf == NULL\n");
265#endif
266 return(-1);
267 }
268 return(buf->alloc);
269}
270
280int
283 if ((buf == NULL) || (buf->error != 0)) {
284#ifdef DEBUG_BUFFER
286 "xmlBufSetAllocationScheme: buf == NULL or in error\n");
287#endif
288 return(-1);
289 }
290 if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
291 (buf->alloc == XML_BUFFER_ALLOC_IO))
292 return(-1);
298 buf->alloc = scheme;
299 if (buf->buffer)
300 buf->buffer->alloc = scheme;
301 return(0);
302 }
303 /*
304 * Switching a buffer ALLOC_IO has the side effect of initializing
305 * the contentIO field with the current content
306 */
308 buf->alloc = XML_BUFFER_ALLOC_IO;
309 buf->contentIO = buf->content;
310 }
311 return(-1);
312}
313
321void
323 if (buf == NULL) {
324#ifdef DEBUG_BUFFER
326 "xmlBufFree: buf == NULL\n");
327#endif
328 return;
329 }
330
331 if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
332 (buf->contentIO != NULL)) {
333 xmlFree(buf->contentIO);
334 } else if ((buf->content != NULL) &&
335 (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
336 xmlFree(buf->content);
337 }
338 xmlFree(buf);
339}
340
347void
349 if ((buf == NULL) || (buf->error != 0)) return;
350 if (buf->content == NULL) return;
352 buf->use = 0;
353 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
354 buf->content = BAD_CAST "";
355 } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
356 (buf->contentIO != NULL)) {
357 size_t start_buf = buf->content - buf->contentIO;
358
359 buf->size += start_buf;
360 buf->content = buf->contentIO;
361 buf->content[0] = 0;
362 } else {
363 buf->content[0] = 0;
364 }
366}
367
380size_t
382 if ((buf == NULL) || (buf->error != 0)) return(0);
384 if (len == 0) return(0);
385 if (len > buf->use) return(0);
386
387 buf->use -= len;
388 if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
389 ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
390 /*
391 * we just move the content pointer, but also make sure
392 * the perceived buffer size has shrunk accordingly
393 */
394 buf->content += len;
395 buf->size -= len;
396
397 /*
398 * sometimes though it maybe be better to really shrink
399 * on IO buffers
400 */
401 if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
402 size_t start_buf = buf->content - buf->contentIO;
403 if (start_buf >= buf->size) {
404 memmove(buf->contentIO, &buf->content[0], buf->use);
405 buf->content = buf->contentIO;
406 buf->content[buf->use] = 0;
407 buf->size += start_buf;
408 }
409 }
410 } else {
411 memmove(buf->content, &buf->content[len], buf->use);
412 buf->content[buf->use] = 0;
413 }
415 return(len);
416}
417
429static size_t
431 size_t size;
432 xmlChar *newbuf;
433
434 if ((buf == NULL) || (buf->error != 0)) return(0);
436
437 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
438 if (len < buf->size - buf->use)
439 return(buf->size - buf->use - 1);
440 if (len >= SIZE_MAX - buf->use) {
441 xmlBufMemoryError(buf, "growing buffer past SIZE_MAX");
442 return(0);
443 }
444
445 if (buf->size > (size_t) len) {
446 size = buf->size > SIZE_MAX / 2 ? SIZE_MAX : buf->size * 2;
447 } else {
448 size = buf->use + len;
449 size = size > SIZE_MAX - 100 ? SIZE_MAX : size + 100;
450 }
451
452 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
453 /*
454 * Used to provide parsing limits
455 */
456 if ((buf->use + len + 1 >= XML_MAX_TEXT_LENGTH) ||
457 (buf->size >= XML_MAX_TEXT_LENGTH)) {
458 xmlBufMemoryError(buf, "buffer error: text too long\n");
459 return(0);
460 }
463 }
464 if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
465 size_t start_buf = buf->content - buf->contentIO;
466
467 newbuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + size);
468 if (newbuf == NULL) {
469 xmlBufMemoryError(buf, "growing buffer");
470 return(0);
471 }
472 buf->contentIO = newbuf;
473 buf->content = newbuf + start_buf;
474 } else {
475 newbuf = (xmlChar *) xmlRealloc(buf->content, size);
476 if (newbuf == NULL) {
477 xmlBufMemoryError(buf, "growing buffer");
478 return(0);
479 }
480 buf->content = newbuf;
481 }
482 buf->size = size;
484 return(buf->size - buf->use - 1);
485}
486
497int
499 size_t ret;
500
501 if ((buf == NULL) || (len < 0)) return(-1);
502 if (len == 0)
503 return(0);
505 if (buf->error != 0)
506 return(-1);
507 return((int) ret);
508}
509
518size_t
520 size_t ret;
521
522 if ((buf == NULL) || (buf->error != 0)) {
523#ifdef DEBUG_BUFFER
525 "xmlBufDump: buf == NULL or in error\n");
526#endif
527 return(0);
528 }
529 if (buf->content == NULL) {
530#ifdef DEBUG_BUFFER
532 "xmlBufDump: buf->content == NULL\n");
533#endif
534 return(0);
535 }
537 if (file == NULL)
538 file = stdout;
539 ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
540 return(ret);
541}
542
552xmlChar *
554{
555 if ((!buf) || (buf->error))
556 return NULL;
557
558 return(buf->content);
559}
560
570xmlChar *
572{
573 if ((!buf) || (buf->error))
574 return NULL;
576
577 return(&buf->content[buf->use]);
578}
579
591int
593 if ((buf == NULL) || (buf->error))
594 return(-1);
596 if (len >= (buf->size - buf->use))
597 return(-1);
598 buf->use += len;
599 buf->content[buf->use] = 0;
601 return(0);
602}
603
613size_t
615{
616 if ((!buf) || (buf->error))
617 return 0;
619
620 return(buf->use);
621}
622
632size_t
634{
635 if ((!buf) || (buf->error))
636 return 0;
638
639 return(buf->use);
640}
641
654size_t
656{
657 if ((!buf) || (buf->error))
658 return 0;
660
661 return((buf->size > buf->use) ? (buf->size - buf->use - 1) : 0);
662}
663
672int
674{
675 if ((!buf) || (buf->error))
676 return(-1);
678
679 return(buf->use == 0);
680}
681
691int
693{
694 size_t newSize;
695 xmlChar* rebuf = NULL;
696 size_t start_buf;
697
698 if ((buf == NULL) || (buf->error))
699 return(0);
701
702 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
703 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
704 /*
705 * Used to provide parsing limits
706 */
707 if (size >= XML_MAX_TEXT_LENGTH) {
708 xmlBufMemoryError(buf, "buffer error: text too long\n");
709 return(0);
710 }
711 }
712
713 /* Don't resize if we don't have to */
714 if (size < buf->size)
715 return 1;
716
717 /* figure out new size */
718 switch (buf->alloc){
721 /*take care of empty case*/
722 if (buf->size == 0) {
723 newSize = (size > SIZE_MAX - 10 ? SIZE_MAX : size + 10);
724 } else {
725 newSize = buf->size;
726 }
727 while (size > newSize) {
728 if (newSize > SIZE_MAX / 2) {
729 xmlBufMemoryError(buf, "growing buffer");
730 return 0;
731 }
732 newSize *= 2;
733 }
734 break;
736 newSize = (size > SIZE_MAX - 10 ? SIZE_MAX : size + 10);
737 break;
739 if (buf->use < BASE_BUFFER_SIZE)
740 newSize = size;
741 else {
742 newSize = buf->size;
743 while (size > newSize) {
744 if (newSize > SIZE_MAX / 2) {
745 xmlBufMemoryError(buf, "growing buffer");
746 return 0;
747 }
748 newSize *= 2;
749 }
750 }
751 break;
752
753 default:
754 newSize = (size > SIZE_MAX - 10 ? SIZE_MAX : size + 10);
755 break;
756 }
757
758 if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
759 start_buf = buf->content - buf->contentIO;
760
761 if (start_buf > newSize) {
762 /* move data back to start */
763 memmove(buf->contentIO, buf->content, buf->use);
764 buf->content = buf->contentIO;
765 buf->content[buf->use] = 0;
766 buf->size += start_buf;
767 } else {
768 rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize);
769 if (rebuf == NULL) {
770 xmlBufMemoryError(buf, "growing buffer");
771 return 0;
772 }
773 buf->contentIO = rebuf;
774 buf->content = rebuf + start_buf;
775 }
776 } else {
777 if (buf->content == NULL) {
778 rebuf = (xmlChar *) xmlMallocAtomic(newSize);
779 buf->use = 0;
780 rebuf[buf->use] = 0;
781 } else if (buf->size - buf->use < 100) {
782 rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
783 } else {
784 /*
785 * if we are reallocating a buffer far from being full, it's
786 * better to make a new allocation and copy only the used range
787 * and free the old one.
788 */
789 rebuf = (xmlChar *) xmlMallocAtomic(newSize);
790 if (rebuf != NULL) {
791 memcpy(rebuf, buf->content, buf->use);
792 xmlFree(buf->content);
793 rebuf[buf->use] = 0;
794 }
795 }
796 if (rebuf == NULL) {
797 xmlBufMemoryError(buf, "growing buffer");
798 return 0;
799 }
800 buf->content = rebuf;
801 }
802 buf->size = newSize;
804
805 return 1;
806}
807
820int
822 size_t needSize;
823
824 if ((str == NULL) || (buf == NULL) || (buf->error))
825 return -1;
827
828 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
829 if (len < -1) {
830#ifdef DEBUG_BUFFER
832 "xmlBufAdd: len < 0\n");
833#endif
834 return -1;
835 }
836 if (len == 0) return 0;
837
838 if (len < 0)
839 len = xmlStrlen(str);
840
841 if (len < 0) return -1;
842 if (len == 0) return 0;
843
844 /* Note that both buf->size and buf->use can be zero here. */
845 if ((size_t) len >= buf->size - buf->use) {
846 if ((size_t) len >= SIZE_MAX - buf->use) {
847 xmlBufMemoryError(buf, "growing buffer past SIZE_MAX");
848 return(-1);
849 }
850 needSize = buf->use + len + 1;
851 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
852 /*
853 * Used to provide parsing limits
854 */
855 if (needSize >= XML_MAX_TEXT_LENGTH) {
856 xmlBufMemoryError(buf, "buffer error: text too long\n");
857 return(-1);
858 }
859 }
860 if (!xmlBufResize(buf, needSize)){
861 xmlBufMemoryError(buf, "growing buffer");
862 return XML_ERR_NO_MEMORY;
863 }
864 }
865
866 memmove(&buf->content[buf->use], str, len*sizeof(xmlChar));
867 buf->use += len;
868 buf->content[buf->use] = 0;
870 return 0;
871}
872
883int
885 if ((buf == NULL) || (buf->error))
886 return(-1);
888 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
889 if (str == NULL) return -1;
890 return xmlBufAdd(buf, str, -1);
891}
892
903int
905 return xmlBufCat(buf, (const xmlChar *) str);
906}
907
920int
922 const xmlChar *cur, *base;
923 if ((buf == NULL) || (buf->error))
924 return(-1);
926 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
927 return(-1);
928 if (xmlStrchr(string, '\"')) {
929 if (xmlStrchr(string, '\'')) {
930#ifdef DEBUG_BUFFER
932 "xmlBufWriteQuotedString: string contains quote and double-quotes !\n");
933#endif
934 xmlBufCCat(buf, "\"");
935 base = cur = string;
936 while(*cur != 0){
937 if(*cur == '"'){
938 if (base != cur)
940 xmlBufAdd(buf, BAD_CAST "&quot;", 6);
941 cur++;
942 base = cur;
943 }
944 else {
945 cur++;
946 }
947 }
948 if (base != cur)
950 xmlBufCCat(buf, "\"");
951 }
952 else{
953 xmlBufCCat(buf, "\'");
954 xmlBufCat(buf, string);
955 xmlBufCCat(buf, "\'");
956 }
957 } else {
958 xmlBufCCat(buf, "\"");
959 xmlBufCat(buf, string);
960 xmlBufCCat(buf, "\"");
961 }
962 return(0);
963}
964
979
980 if (buffer == NULL)
981 return(NULL);
982
983 ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
984 if (ret == NULL) {
985 xmlBufMemoryError(NULL, "creating buffer");
986 return(NULL);
987 }
988 ret->use = buffer->use;
989 ret->size = buffer->size;
991 ret->error = 0;
992 ret->buffer = buffer;
993 ret->alloc = buffer->alloc;
994 ret->content = buffer->content;
995 ret->contentIO = buffer->contentIO;
996
997 return(ret);
998}
999
1015
1016 if (buf == NULL)
1017 return(NULL);
1019 if ((buf->error) || (buf->buffer == NULL)) {
1020 xmlBufFree(buf);
1021 return(NULL);
1022 }
1023
1024 ret = buf->buffer;
1025 /*
1026 * What to do in case of error in the buffer ???
1027 */
1028 if (buf->use > INT_MAX) {
1029 /*
1030 * Worse case, we really allocated and used more than the
1031 * maximum allowed memory for an xmlBuffer on this architecture.
1032 * Keep the buffer but provide a truncated size value.
1033 */
1034 xmlBufOverflowError(buf, "Used size too big for xmlBuffer");
1035 ret->use = INT_MAX;
1036 ret->size = INT_MAX;
1037 } else if (buf->size > INT_MAX) {
1038 /*
1039 * milder case, we allocated more than the maximum allowed memory
1040 * for an xmlBuffer on this architecture, but used less than the
1041 * limit.
1042 * Keep the buffer but provide a truncated size value.
1043 */
1044 xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer");
1045 ret->use = (int) buf->use;
1046 ret->size = INT_MAX;
1047 } else {
1048 ret->use = (int) buf->use;
1049 ret->size = (int) buf->size;
1050 }
1051 ret->alloc = buf->alloc;
1052 ret->content = buf->content;
1053 ret->contentIO = buf->contentIO;
1054 xmlFree(buf);
1055 return(ret);
1056}
1057
1067int
1069 int ret = 0;
1070
1071 if ((buf == NULL) || (buf->error)) {
1073 return(-1);
1074 }
1076 if ((buffer != NULL) && (buffer->content != NULL) &&
1077 (buffer->use > 0)) {
1078 ret = xmlBufAdd(buf, buffer->content, buffer->use);
1079 }
1081 return(ret);
1082}
1083
1093int
1095 if ((input == NULL) || (buf == NULL) || (buf->error))
1096 return(-1);
1098 input->base = input->cur = buf->content;
1099 input->end = &buf->content[buf->use];
1100 return(0);
1101}
1102
1112size_t
1114 size_t base;
1115
1116 if ((input == NULL) || (buf == NULL) || (buf->error))
1117 return(-1);
1119 base = input->base - buf->content;
1120 /*
1121 * We could do some pointer arithmetic checks but that's probably
1122 * sufficient.
1123 */
1124 if (base > buf->size) {
1125 xmlBufOverflowError(buf, "Input reference outside of the buffer");
1126 base = 0;
1127 }
1128 return(base);
1129}
1130
1143int
1145 size_t base, size_t cur) {
1146 if (input == NULL)
1147 return(-1);
1148 if ((buf == NULL) || (buf->error)) {
1149 input->base = input->cur = input->end = BAD_CAST "";
1150 return(-1);
1151 }
1153 input->base = &buf->content[base];
1154 input->cur = input->base + cur;
1155 input->end = &buf->content[buf->use];
1156 return(0);
1157}
1158
size_t xmlBufAvail(const xmlBufPtr buf)
Definition: buf.c:655
int xmlBufAddLen(xmlBufPtr buf, size_t len)
Definition: buf.c:592
void xmlBufEmpty(xmlBufPtr buf)
Definition: buf.c:348
static size_t xmlBufGrowInternal(xmlBufPtr buf, size_t len)
Definition: buf.c:430
xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer)
Definition: buf.c:977
int xmlBufGetAllocationScheme(xmlBufPtr buf)
Definition: buf.c:260
int xmlBufResize(xmlBufPtr buf, size_t size)
Definition: buf.c:692
xmlChar * xmlBufEnd(xmlBufPtr buf)
Definition: buf.c:571
size_t xmlBufLength(const xmlBufPtr buf)
Definition: buf.c:614
static void xmlBufOverflowError(xmlBufPtr buf, const char *extra)
Definition: buf.c:107
#define SIZE_MAX
Definition: buf.c:30
#define UPDATE_COMPAT(buf)
Definition: buf.c:60
int xmlBufIsEmpty(const xmlBufPtr buf)
Definition: buf.c:673
void xmlBufFree(xmlBufPtr buf)
Definition: buf.c:322
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
xmlChar * xmlBufDetach(xmlBufPtr buf)
Definition: buf.c:196
xmlBufPtr xmlBufCreateStatic(void *mem, size_t size)
Definition: buf.c:230
xmlBufPtr xmlBufCreateSize(size_t size)
Definition: buf.c:155
xmlBufPtr xmlBufCreate(void)
Definition: buf.c:122
int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer)
Definition: buf.c:1068
xmlChar * xmlBufContent(const xmlBuf *buf)
Definition: buf.c:553
int xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme)
Definition: buf.c:281
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1113
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string)
Definition: buf.c:921
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf)
Definition: buf.c:1013
size_t xmlBufDump(FILE *file, xmlBufPtr buf)
Definition: buf.c:519
size_t xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:633
#define CHECK_COMPAT(buf)
Definition: buf.c:71
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len)
Definition: buf.c:821
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, size_t base, size_t cur)
Definition: buf.c:1144
int xmlBufGrow(xmlBufPtr buf, int len)
Definition: buf.c:498
static void xmlBufMemoryError(xmlBufPtr buf, const char *extra)
Definition: buf.c:92
int xmlBufCat(xmlBufPtr buf, const xmlChar *str)
Definition: buf.c:884
int xmlBufCCat(xmlBufPtr buf, const char *str)
Definition: buf.c:904
size_t xmlBufShrink(xmlBufPtr buf, size_t len)
Definition: buf.c:381
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
GLenum GLenum GLenum input
Definition: glext.h:9031
@ extra
Definition: id3.c:95
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
#define INT_MAX
Definition: intsafe.h:150
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
char string[160]
Definition: util.h:11
#define XML_MAX_TEXT_LENGTH
const WCHAR * str
DWORD scheme
XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme
Definition: globals.h:293
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBVAR int xmlDefaultBufferSize
Definition: globals.h:303
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
XMLPUBFUN void XMLCALL xmlBufferFree(xmlBufferPtr buf)
xmlBufferAllocationScheme
Definition: tree.h:74
@ XML_BUFFER_ALLOC_BOUNDED
Definition: tree.h:80
@ XML_BUFFER_ALLOC_EXACT
Definition: tree.h:76
@ XML_BUFFER_ALLOC_IMMUTABLE
Definition: tree.h:77
@ XML_BUFFER_ALLOC_IO
Definition: tree.h:78
@ XML_BUFFER_ALLOC_DOUBLEIT
Definition: tree.h:75
@ XML_BUFFER_ALLOC_HYBRID
Definition: tree.h:79
#define BASE_BUFFER_SIZE
Definition: tree.h:56
xmlBuf * xmlBufPtr
Definition: tree.h:114
Definition: buf.c:43
xmlChar * contentIO
Definition: buf.c:48
xmlChar * content
Definition: buf.c:44
unsigned int compat_use
Definition: buf.c:45
unsigned int compat_size
Definition: buf.c:46
size_t use
Definition: buf.c:49
xmlBufferPtr buffer
Definition: buf.c:51
xmlBufferAllocationScheme alloc
Definition: buf.c:47
size_t size
Definition: buf.c:50
int error
Definition: buf.c:52
Definition: fci.c:127
Definition: mem.c:349
int ret
@ XML_FROM_BUFFER
Definition: xmlerror.h:66
@ XML_BUF_OVERFLOW
Definition: xmlerror.h:835
@ XML_ERR_NO_MEMORY
Definition: xmlerror.h:102
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:325
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
unsigned char xmlChar
Definition: xmlstring.h:28