cmd: DIR command outputs free space for the path.
[wine.git] / dlls / mfreadwrite / mf_private.h
blobd8b44712b4a351ced1a46960931ea67b9b4fd043
1 /*
2 * Copyright 2020 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "mferror.h"
21 extern HRESULT create_sink_writer_from_url(const WCHAR *url, IMFByteStream *stream,
22 IMFAttributes *attributes, REFIID riid, void **out);
23 extern HRESULT create_sink_writer_from_sink(IMFMediaSink *sink, IMFAttributes *attributes,
24 REFIID riid, void **out);
26 static inline BOOL mf_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
28 size_t new_capacity, max_capacity;
29 void *new_elements;
31 if (count <= *capacity)
32 return TRUE;
34 max_capacity = ~(SIZE_T)0 / size;
35 if (count > max_capacity)
36 return FALSE;
38 new_capacity = max(4, *capacity);
39 while (new_capacity < count && new_capacity <= max_capacity / 2)
40 new_capacity *= 2;
41 if (new_capacity < count)
42 new_capacity = max_capacity;
44 if (!(new_elements = realloc(*elements, new_capacity * size)))
45 return FALSE;
47 *elements = new_elements;
48 *capacity = new_capacity;
50 return TRUE;