src/dpdk/lib/librte_eal/windows/eal_memory.c
static int
mem_free(void *addr, size_t size, bool reserved)
{
	MEMORY_BASIC_INFORMATION info;
	HANDLE process;

	process = GetCurrentProcess();

	if (VirtualQueryEx(
			process, addr, &info, sizeof(info)) != sizeof(info)) {
		RTE_LOG_WIN32_ERR("VirtualQueryEx(%p)", addr);
		return -1;
	}

	if (reserved && (info.State != MEM_RESERVE))
		return 1;

	/* Free complete region. */
	if ((addr == info.AllocationBase) && (size == info.RegionSize)) {
		if (!VirtualFreeEx(process, addr, 0, MEM_RELEASE)) {
			RTE_LOG_WIN32_ERR("VirtualFreeEx(%p, 0, release)",
				addr);
		}
		return 0;
	}

	/* Split the part to be freed and the remaining reservation. */
	if (!VirtualFreeEx(process, addr, size,
			MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) {
		RTE_LOG_WIN32_ERR(
			"VirtualFreeEx(%p, %zu, preserve placeholder)",
			addr, size);
		return -1;
	}

	/* Actually free reservation part. */
	if (!VirtualFreeEx(process, addr, 0, MEM_RELEASE)) {
		RTE_LOG_WIN32_ERR("VirtualFreeEx(%p, 0, release)", addr);
		return -1;
	}

	return 0;
}
/**
 * Free a reserved memory region in full or in part.
 *
 * @param addr
 *  Starting address of the area to free.
 * @param size
 *  Number of bytes to free. Must be a multiple of page size.
 * @param reserved
 *  Fail if the region is not in reserved state.
 * @return
 *  * 0 on successful deallocation;
 *  * 1 if region must be in reserved state but it is not;
 *  * (-1) on system API failures.
 */
Free a reserved memory region in full or in part.
@param addr
Starting address of the area to free.
@param size
Number of bytes to free. Must be a multiple of page size.
@param reserved
Fail if the region is not in reserved state.
@return
0 on successful deallocation;
1 if region must be in reserved state but it is not;
(-1) on system API failures.
Free a reserved memory region in full or in part . @param addr Starting address of the area to free . @param size Number of bytes to free . Must be a multiple of page size . @param reserved Fail if the region is not in reserved state . @return 0 on successful deallocation ; 1 if region must be in reserved state but it is not ; ( - 1 ) on system API failures .
static int
mem_free(void *addr, size_t size, bool reserved)
{
	MEMORY_BASIC_INFORMATION info;
	HANDLE process;
	process = GetCurrentProcess();
	if (VirtualQueryEx(
			process, addr, &info, sizeof(info)) != sizeof(info)) {
		RTE_LOG_WIN32_ERR("VirtualQueryEx(%p)", addr);
		return -1;
	}
	if (reserved && (info.State != MEM_RESERVE))
		return 1;
	if ((addr == info.AllocationBase) && (size == info.RegionSize)) {
		if (!VirtualFreeEx(process, addr, 0, MEM_RELEASE)) {
			RTE_LOG_WIN32_ERR("VirtualFreeEx(%p, 0, release)",
				addr);
		}
		return 0;
	}
	if (!VirtualFreeEx(process, addr, size,
			MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) {
		RTE_LOG_WIN32_ERR(
			"VirtualFreeEx(%p, %zu, preserve placeholder)",
			addr, size);
		return -1;
	}
	if (!VirtualFreeEx(process, addr, 0, MEM_RELEASE)) {
		RTE_LOG_WIN32_ERR("VirtualFreeEx(%p, 0, release)", addr);
		return -1;
	}
	return 0;
}
static int mem_free ( void * addr , size_t size , bool reserved ) { MEMORY_BASIC_INFORMATION info ; HANDLE process ; process = GetCurrentProcess ( ) ; if ( VirtualQueryEx ( process , addr , & info , sizeof ( info ) ) != sizeof ( info ) ) { RTE_LOG_WIN32_ERR ( " " , addr ) ; return -1 ; } if ( reserved && ( info . State != MEM_RESERVE ) ) return 1 ; if ( ( addr == info . AllocationBase ) && ( size == info . RegionSize ) ) { if ( ! VirtualFreeEx ( process , addr , 0 , MEM_RELEASE ) ) { RTE_LOG_WIN32_ERR ( " " , addr ) ; } return 0 ; } if ( ! VirtualFreeEx ( process , addr , size , MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ) ) { RTE_LOG_WIN32_ERR ( " " , addr , size ) ; return -1 ; } if ( ! VirtualFreeEx ( process , addr , 0 , MEM_RELEASE ) ) { RTE_LOG_WIN32_ERR ( " " , addr ) ; return -1 ; } return 0 ; }
Free a reserved memory region in full or in part.
Free a reserved memory region in full or in part .
/* Free complete region. */ /* Split the part to be freed and the remaining reservation. */ /* Actually free reservation part. */