예제 #1
0
void allocAlignedRealloc(bool bFree)
{
    void* leaked = _aligned_offset_malloc(64, 16, 1);
    int* leaked_memory = (int*)_aligned_malloc(64, 16);
    int* leaked_memory_dbg = (int*)_aligned_malloc_dbg(32, 16, __FILE__, __LINE__);
    leaked = (int*)_aligned_offset_realloc(leaked, 48, 16, 2);
    leaked_memory = (int*)_aligned_realloc(leaked_memory, 128, 16);
    leaked_memory_dbg = (int*)_aligned_realloc_dbg(leaked_memory_dbg, 48, 16, __FILE__, __LINE__);
    leaked = (int*)_aligned_offset_recalloc(leaked, 1, 52, 16, 2);
    leaked_memory = (int*)_aligned_recalloc(leaked_memory, 1, 132, 16);
    leaked_memory_dbg = (int*)_aligned_recalloc_dbg(leaked_memory_dbg, 1, 64, 16, __FILE__, __LINE__);
    if (bFree)
    {
        _aligned_free(leaked);
        _aligned_free(leaked_memory);
        _aligned_free_dbg(leaked_memory_dbg);
    }
}
예제 #2
0
void * __cdecl _aligned_offset_realloc_dbg( void * memblock, size_t size, size_t align, 
                 size_t offset, const char * f_name, int line_n)
{
    return _aligned_offset_realloc(memblock, size, align, offset);
}
예제 #3
0
파일: TsStream.cpp 프로젝트: logue/TvCas
void *CTsPacket::ReAllocate(void *pBuffer, size_t Size)
{
	return _aligned_offset_realloc(pBuffer, Size, 16, 4);
}
예제 #4
0
파일: heap.c 프로젝트: pstrealer/wine
/*********************************************************************
 *		_aligned_realloc (MSVCRT.@)
 */
void * CDECL _aligned_realloc(void *memblock, MSVCRT_size_t size, MSVCRT_size_t alignment)
{
    TRACE("(%p, %lu, %lu)\n", memblock, size, alignment);
    return _aligned_offset_realloc(memblock, size, alignment, 0);
}
예제 #5
0
int TestAlignment(int argc, char* argv[])
{
	void* ptr;
	size_t alignment;
	size_t offset;

	/* Alignment should be 2^N where N is a positive integer */

	alignment = 16;
	offset = 5;

	/* _aligned_malloc */

	ptr = _aligned_malloc(100, alignment);

	if (ptr == NULL)
	{
		printf("Error allocating aligned memory.\n");
		return -1;
	}

	if (((size_t) ptr % alignment) != 0)
	{
		printf("This pointer, %d, is not aligned on %d\n", ptr, alignment);
		return -1;
	}

	/* _aligned_realloc */
	
	ptr = _aligned_realloc(ptr, 200, alignment);
	
	if (((size_t) ptr % alignment) != 0)
	{
		printf("This pointer, %d, is not aligned on %d\n", ptr, alignment);
		return -1;
	}
	
	_aligned_free(ptr);

	/* _aligned_offset_malloc */

	ptr = _aligned_offset_malloc(200, alignment, offset);

	if (ptr == NULL)
	{
		printf("Error reallocating aligned offset memory.");
		return -1;
	}

	if (((((size_t) ptr) + offset) % alignment) != 0)
	{
		printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment);
		return -1;
	}

	/* _aligned_offset_realloc */

	ptr = _aligned_offset_realloc(ptr, 200, alignment, offset);
	
	if (ptr == NULL)
	{
		printf("Error reallocating aligned offset memory.");
		return -1;
	}

	if (((((size_t) ptr) + offset) % alignment) != 0)
	{
		printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment);
		return -1;
	}

	/* _aligned_free works for both _aligned_malloc and _aligned_offset_malloc. free() should not be used. */
	_aligned_free(ptr);

	return 0;
}
예제 #6
0
파일: alignment.c 프로젝트: CoryXie/FreeRDP
void* _aligned_realloc(void* memblock, size_t size, size_t alignment)
{
	return _aligned_offset_realloc(memblock, size, alignment, 0);
}