mxwriter.c (bab6b90f) mxwriter.c (eb44c20c)
1/*
2 * MXWriter implementation
3 *
4 * Copyright 2011-2014, 2016 Nikolay Sivov for CodeWeavers
5 * Copyright 2011 Thomas Mullaly
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public

--- 484 unchanged lines hidden (view full) ---

493 static const WCHAR gtW[] = {'&','g','t',';'};
494
495 const int default_alloc = 100;
496 const int grow_thresh = 10;
497 int p = *len, conv_len;
498 WCHAR *ptr, *ret;
499
500 /* default buffer size to something if length is unknown */
1/*
2 * MXWriter implementation
3 *
4 * Copyright 2011-2014, 2016 Nikolay Sivov for CodeWeavers
5 * Copyright 2011 Thomas Mullaly
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public

--- 484 unchanged lines hidden (view full) ---

493 static const WCHAR gtW[] = {'&','g','t',';'};
494
495 const int default_alloc = 100;
496 const int grow_thresh = 10;
497 int p = *len, conv_len;
498 WCHAR *ptr, *ret;
499
500 /* default buffer size to something if length is unknown */
501 conv_len = *len == -1 ? default_alloc : max(2**len, default_alloc);
501 conv_len = max(2**len, default_alloc);
502 ptr = ret = heap_alloc(conv_len*sizeof(WCHAR));
503
502 ptr = ret = heap_alloc(conv_len*sizeof(WCHAR));
503
504 while (*str && p)
504 while (p)
505 {
506 if (ptr - ret > conv_len - grow_thresh)
507 {
508 int written = ptr - ret;
509 conv_len *= 2;
510 ptr = ret = heap_realloc(ret, conv_len*sizeof(WCHAR));
511 ptr += written;
512 }

--- 21 unchanged lines hidden (view full) ---

534 }
535 /* fallthrough for text mode */
536 default:
537 *ptr++ = *str;
538 break;
539 }
540
541 str++;
505 {
506 if (ptr - ret > conv_len - grow_thresh)
507 {
508 int written = ptr - ret;
509 conv_len *= 2;
510 ptr = ret = heap_realloc(ret, conv_len*sizeof(WCHAR));
511 ptr += written;
512 }

--- 21 unchanged lines hidden (view full) ---

534 }
535 /* fallthrough for text mode */
536 default:
537 *ptr++ = *str;
538 break;
539 }
540
541 str++;
542 if (*len != -1) p--;
542 p--;
543 }
544
543 }
544
545 if (*len != -1) *len = ptr-ret;
545 *len = ptr-ret;
546 *++ptr = 0;
547
548 return ret;
549}
550
551static void write_prolog_buffer(mxwriter *writer)
552{
553 static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='};

--- 1647 unchanged lines hidden (view full) ---

2201{
2202 mxwriter *This = impl_from_IVBSAXContentHandler( iface );
2203
2204 TRACE("(%p)->(%p)\n", This, chars);
2205
2206 if (!chars)
2207 return E_POINTER;
2208
546 *++ptr = 0;
547
548 return ret;
549}
550
551static void write_prolog_buffer(mxwriter *writer)
552{
553 static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='};

--- 1647 unchanged lines hidden (view full) ---

2201{
2202 mxwriter *This = impl_from_IVBSAXContentHandler( iface );
2203
2204 TRACE("(%p)->(%p)\n", This, chars);
2205
2206 if (!chars)
2207 return E_POINTER;
2208
2209 return ISAXContentHandler_characters(&This->ISAXContentHandler_iface, *chars, -1);
2209 return ISAXContentHandler_characters(&This->ISAXContentHandler_iface, *chars, SysStringLen(*chars));
2210}
2211
2212static HRESULT WINAPI VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler *iface, BSTR *chars)
2213{
2214 mxwriter *This = impl_from_IVBSAXContentHandler( iface );
2215
2216 TRACE("(%p)->(%p)\n", This, chars);
2217

--- 1365 unchanged lines hidden ---
2210}
2211
2212static HRESULT WINAPI VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler *iface, BSTR *chars)
2213{
2214 mxwriter *This = impl_from_IVBSAXContentHandler( iface );
2215
2216 TRACE("(%p)->(%p)\n", This, chars);
2217

--- 1365 unchanged lines hidden ---