ReactOS 0.4.16-dev-715-ga1a169f
expand.cpp File Reference
#include <corecrt_internal.h>
#include <malloc.h>
Include dependency graph for expand.cpp:

Go to the source code of this file.

Functions

static __inline bool is_contraction_possible (size_t const old_size) throw ()
 
 __declspec (noinline) void *__cdecl _expand_base(void *const block
 
 _VALIDATE_RETURN_NOEXC (size<=_HEAP_MAXREQ, ENOMEM, nullptr)
 
 if (new_block !=nullptr) return new _block
 
 if (new_size<=old_size &&!is_contraction_possible(old_size)) return block
 

Variables

size_t const size
 
size_t const old_size = static_cast<size_t>(HeapSize(__acrt_heap, 0, block))
 
size_t const new_size = size == 0 ? 1 : size
 
voidnew_block = HeapReAlloc(__acrt_heap, HEAP_REALLOC_IN_PLACE_ONLY, block, new_size)
 
 errno = __acrt_errno_from_os_error(GetLastError())
 
return nullptr
 

Function Documentation

◆ __declspec()

__declspec ( noinline  ) const

◆ _VALIDATE_RETURN_NOEXC()

_VALIDATE_RETURN_NOEXC ( size<=  _HEAP_MAXREQ,
ENOMEM  ,
nullptr   
)

◆ if() [1/2]

if ( new_block = nullptr)
new

◆ if() [2/2]

if ( new_size<=old_size &&!  is_contraction_possibleold_size)

◆ is_contraction_possible()

static __inline bool is_contraction_possible ( size_t const  old_size)
throw (
)
static

Definition at line 26 of file expand.cpp.

27{
28 // Check if object allocated on low fragmentation heap.
29 //The LFH can only allocate blocks up to 16KB in size.
30 if (old_size <= 0x4000)
31 {
32 LONG heap_type = -1;
36 &heap_type,
37 sizeof(heap_type),
38 nullptr))
39 {
40 return FALSE;
41 }
42 return heap_type != 2;
43 }
44 // Contraction possible for objects not on the LFH
45 return TRUE;
46}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
size_t const old_size
Definition: expand.cpp:65
HANDLE __acrt_heap
Definition: heap_handle.cpp:15
BOOL WINAPI HeapQueryInformation(HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, PVOID HeapInformation OPTIONAL, SIZE_T HeapInformationLength OPTIONAL, PSIZE_T ReturnLength OPTIONAL)
Definition: heapmem.c:314
@ HeapCompatibilityInformation
Definition: rtltypes.h:488
long LONG
Definition: pedump.c:60

Variable Documentation

◆ errno

Definition at line 77 of file expand.cpp.

◆ new_block

Definition at line 68 of file expand.cpp.

◆ new_size

size_t const new_size = size == 0 ? 1 : size

Definition at line 66 of file expand.cpp.

Referenced by _bdf_readstream(), add_index(), add_line_to_buffer(), add_name(), alloc_global_prop(), alloc_user_entry(), append_const_set(), append_data(), append_string_len(), BlockChainStream_UpdateIndexCache(), build_multi_string_value(), cff_index_get_pointers(), convert_dib_to_bmp(), convert_input_data(), d3d8_allocate_handle(), d3d_execute_buffer_SetExecuteData(), d3dx_pool_sync_shared_parameter(), ddraw_allocate_handle(), DECLARE_INTERFACE_(), dxbc_add_section(), find_arb_pshader(), find_arb_vshader(), find_glsl_domain_shader(), find_glsl_geometry_shader(), find_glsl_hull_shader(), find_glsl_pshader(), find_glsl_vshader(), ft_lzwstate_prefix_grow(), ft_lzwstate_stack_grow(), ft_mem_qrealloc(), ft_realloc(), ResizeManager::HandleSize(), ID3DXMatrixStackImpl_Pop(), ID3DXMatrixStackImpl_Push(), ITERATE_WriteRegistryValues(), LISTBOX_InitStorage(), mem_trim(), strstreambuf::overflow(), parse_security_url(), processRegLines(), ps_table_add(), realloc_dbg_nolock(), reallocate_t1_table(), record_parameter(), deque< _Tp, >::resize(), resize_mapping(), audio_membuffer::resize_mem_(), RtlSetEnvironmentVariable(), set_size(), shader_record_sample(), __crt_win32_buffer< Character, ResizePolicy >::size(), store_user_dirid(), strbuf_ensure_size(), streams_resize_table(), test_overwrite(), TestLockBytes_WriteAt(), TIM_SORT_RESIZE(), TransactedSnapshotImpl_FindFreeEntry(), TRIO_ARGS2(), wined3d_cs_st_require_space(), xmlParseCommentComplex(), and xmlParsePI().

◆ nullptr

return nullptr

◆ old_size

◆ size

Initial value:
{
_VALIDATE_RETURN (block != nullptr, EINVAL, nullptr)
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
static unsigned int block
Definition: xmlmemory.c:101

Definition at line 59 of file expand.cpp.