mf: Use CRT allocation functions.
[wine.git] / dlls / mf / mf_private.h
blob2f81eaa13b0339e3b1ae7849a2e867c577325985
1 /*
2 * Copyright 2019 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"
20 #include "mfidl.h"
21 #include "mfapi.h"
23 #include "wine/debug.h"
25 static inline BOOL mf_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
27 size_t new_capacity, max_capacity;
28 void *new_elements;
30 if (count <= *capacity)
31 return TRUE;
33 max_capacity = ~(SIZE_T)0 / size;
34 if (count > max_capacity)
35 return FALSE;
37 new_capacity = max(4, *capacity);
38 while (new_capacity < count && new_capacity <= max_capacity / 2)
39 new_capacity *= 2;
40 if (new_capacity < count)
41 new_capacity = max_capacity;
43 if (!(new_elements = realloc(*elements, new_capacity * size)))
44 return FALSE;
46 *elements = new_elements;
47 *capacity = new_capacity;
49 return TRUE;
52 struct activate_funcs
54 HRESULT (*create_object)(IMFAttributes *attributes, void *context, IUnknown **object);
55 void (*shutdown_object)(void *context, IUnknown *object);
56 void (*free_private)(void *context);
59 HRESULT create_activation_object(void *context, const struct activate_funcs *funcs, IMFActivate **ret) DECLSPEC_HIDDEN;
61 static inline const char *debugstr_time(LONGLONG time)
63 ULONGLONG abstime = time >= 0 ? time : -time;
64 unsigned int i = 0, j = 0;
65 char buffer[23], rev[23];
67 while (abstime || i <= 8)
69 buffer[i++] = '0' + (abstime % 10);
70 abstime /= 10;
71 if (i == 7) buffer[i++] = '.';
73 if (time < 0) buffer[i++] = '-';
75 while (i--) rev[j++] = buffer[i];
76 while (rev[j-1] == '0' && rev[j-2] != '.') --j;
77 rev[j] = 0;
79 return wine_dbg_sprintf("%s", rev);
82 extern BOOL mf_is_sample_copier_transform(IMFTransform *transform) DECLSPEC_HIDDEN;
83 extern HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj) DECLSPEC_HIDDEN;