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
21 #include "wine/heap.h"
22 #include "wine/debug.h"
24 static inline BOOL
mf_array_reserve(void **elements
, size_t *capacity
, size_t count
, size_t size
)
26 size_t new_capacity
, max_capacity
;
29 if (count
<= *capacity
)
32 max_capacity
= ~(SIZE_T
)0 / size
;
33 if (count
> max_capacity
)
36 new_capacity
= max(4, *capacity
);
37 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
39 if (new_capacity
< count
)
40 new_capacity
= max_capacity
;
42 if (!(new_elements
= heap_realloc(*elements
, new_capacity
* size
)))
45 *elements
= new_elements
;
46 *capacity
= new_capacity
;
53 HRESULT (*create_object
)(IMFAttributes
*attributes
, void *context
, IUnknown
**object
);
54 void (*shutdown_object
)(void *context
, IUnknown
*object
);
55 void (*free_private
)(void *context
);
58 HRESULT
create_activation_object(void *context
, const struct activate_funcs
*funcs
, IMFActivate
**ret
) DECLSPEC_HIDDEN
;
60 static inline const char *debugstr_time(LONGLONG time
)
62 ULONGLONG abstime
= time
>= 0 ? time
: -time
;
63 unsigned int i
= 0, j
= 0;
64 char buffer
[23], rev
[23];
66 while (abstime
|| i
<= 8)
68 buffer
[i
++] = '0' + (abstime
% 10);
70 if (i
== 7) buffer
[i
++] = '.';
72 if (time
< 0) buffer
[i
++] = '-';
74 while (i
--) rev
[j
++] = buffer
[i
];
75 while (rev
[j
-1] == '0' && rev
[j
-2] != '.') --j
;
78 return wine_dbg_sprintf("%s", rev
);