⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utalloc.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
	}	/* Mark the segment as deleted */	MEMSET (&address->user_space, 0xEA, address->size);	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", address->size));	acpi_ut_release_mutex (ACPI_MTX_MEMORY);	return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    Acpi_ut_dump_allocation_info * * PARAMETERS: * * RETURN:      None * * DESCRIPTION: Print some info about the outstanding allocations. * ******************************************************************************/voidacpi_ut_dump_allocation_info (	void){/*	ACPI_MEMORY_LIST        *Mem_list;*/	FUNCTION_TRACE ("Ut_dump_allocation_info");/*	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Current allocations",			  Mem_list->Current_count,			  ROUND_UP_TO_1K (Mem_list->Current_size)));	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",			  Mem_list->Max_concurrent_count,			  ROUND_UP_TO_1K (Mem_list->Max_concurrent_size)));	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",			  Running_object_count,			  ROUND_UP_TO_1K (Running_object_size)));	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",			  Running_alloc_count,			  ROUND_UP_TO_1K (Running_alloc_size)));	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Current Nodes",			  Acpi_gbl_Current_node_count,			  ROUND_UP_TO_1K (Acpi_gbl_Current_node_size)));	ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,			  ("%30s: %4d (%3d Kb)\n", "Max Nodes",			  Acpi_gbl_Max_concurrent_node_count,			  ROUND_UP_TO_1K ((Acpi_gbl_Max_concurrent_node_count * sizeof (acpi_namespace_node)))));*/	return_VOID;}/******************************************************************************* * * FUNCTION:    Acpi_ut_dump_allocations * * PARAMETERS:  Component           - Component(s) to dump info for. *              Module              - Module to dump info for.  NULL means all. * * RETURN:      None * * DESCRIPTION: Print a list of all outstanding allocations. * ******************************************************************************/voidacpi_ut_dump_allocations (	u32                     component,	NATIVE_CHAR             *module){	acpi_debug_mem_block    *element;	u32                     i;	FUNCTION_TRACE ("Ut_dump_allocations");	element = acpi_gbl_memory_lists[0].list_head;	if (element == NULL) {		ACPI_DEBUG_PRINT ((ACPI_DB_OK,				"No outstanding allocations.\n"));		return_VOID;	}	/*	 * Walk the allocation list.	 */	acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);	ACPI_DEBUG_PRINT ((ACPI_DB_OK,		"Outstanding allocations:\n"));	for (i = 1; ; i++)  /* Just a counter */ {		if ((element->component & component) &&			((module == NULL) || (0 == STRCMP (module, element->module)))) {			if (((acpi_operand_object  *)(&element->user_space))->common.type != ACPI_CACHED_OBJECT) {				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,						 "%p Len %04X %9.9s-%d",						 &element->user_space, element->size, element->module,						 element->line));				/* Most of the elements will be internal objects. */				switch (((acpi_operand_object  *)					(&element->user_space))->common.data_type) {				case ACPI_DESC_TYPE_INTERNAL:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" Obj_type %12.12s R%d",							acpi_ut_get_type_name (((acpi_operand_object *)(&element->user_space))->common.type),							((acpi_operand_object *)(&element->user_space))->common.reference_count));					break;				case ACPI_DESC_TYPE_PARSER:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" Parse_obj Opcode %04X",							((acpi_parse_object *)(&element->user_space))->opcode));					break;				case ACPI_DESC_TYPE_NAMED:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" Node %4.4s",							(char*)&((acpi_namespace_node *)(&element->user_space))->name));					break;				case ACPI_DESC_TYPE_STATE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" Untyped State_obj"));					break;				case ACPI_DESC_TYPE_STATE_UPDATE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" UPDATE State_obj"));					break;				case ACPI_DESC_TYPE_STATE_PACKAGE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" PACKAGE State_obj"));					break;				case ACPI_DESC_TYPE_STATE_CONTROL:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" CONTROL State_obj"));					break;				case ACPI_DESC_TYPE_STATE_RPSCOPE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" ROOT-PARSE-SCOPE State_obj"));					break;				case ACPI_DESC_TYPE_STATE_PSCOPE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" PARSE-SCOPE State_obj"));					break;				case ACPI_DESC_TYPE_STATE_WSCOPE:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" WALK-SCOPE State_obj"));					break;				case ACPI_DESC_TYPE_STATE_RESULT:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" RESULT State_obj"));					break;				case ACPI_DESC_TYPE_STATE_NOTIFY:					ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,							" NOTIFY State_obj"));					break;				}				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\n"));			}		}		if (element->next == NULL) {			break;		}		element = element->next;	}	acpi_ut_release_mutex (ACPI_MTX_MEMORY);	ACPI_DEBUG_PRINT ((ACPI_DB_OK,		"Total number of unfreed allocations = %d(%X)\n", i,i));	return_VOID;}/******************************************************************************* * * FUNCTION:    Acpi_ut_allocate * * PARAMETERS:  Size                - Size of the allocation *              Component           - Component type of caller *              Module              - Source file name of caller *              Line                - Line number of caller * * RETURN:      Address of the allocated memory on success, NULL on failure. * * DESCRIPTION: The subsystem's equivalent of malloc. * ******************************************************************************/void *acpi_ut_allocate (	u32                     size,	u32                     component,	NATIVE_CHAR             *module,	u32                     line){	acpi_debug_mem_block    *address;	acpi_status             status;	FUNCTION_TRACE_U32 ("Ut_allocate", size);	/* Check for an inadvertent size of zero bytes */	if (!size) {		_REPORT_ERROR (module, line, component,				("Ut_allocate: Attempt to allocate zero bytes\n"));		size = 1;	}	address = acpi_os_allocate (size + sizeof (acpi_debug_mem_block));	if (!address) {		/* Report allocation error */		_REPORT_ERROR (module, line, component,				("Ut_allocate: Could not allocate size %X\n", size));		return_PTR (NULL);	}	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,			  MEM_MALLOC, component, module, line);	if (ACPI_FAILURE (status)) {		acpi_os_free (address);		return_PTR (NULL);	}	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));	return_PTR ((void *) &address->user_space);}/******************************************************************************* * * FUNCTION:    Acpi_ut_callocate * * PARAMETERS:  Size                - Size of the allocation *              Component           - Component type of caller *              Module              - Source file name of caller *              Line                - Line number of caller * * RETURN:      Address of the allocated memory on success, NULL on failure. * * DESCRIPTION: Subsystem equivalent of calloc. * ******************************************************************************/void *acpi_ut_callocate (	u32                     size,	u32                     component,	NATIVE_CHAR             *module,	u32                     line){	acpi_debug_mem_block    *address;	acpi_status             status;	FUNCTION_TRACE_U32 ("Ut_callocate", size);	/* Check for an inadvertent size of zero bytes */	if (!size) {		_REPORT_ERROR (module, line, component,				("Ut_callocate: Attempt to allocate zero bytes\n"));		return_PTR (NULL);	}	address = acpi_os_callocate (size + sizeof (acpi_debug_mem_block));	if (!address) {		/* Report allocation error */		_REPORT_ERROR (module, line, component,				("Ut_callocate: Could not allocate size %X\n", size));		return_PTR (NULL);	}	status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,			   MEM_CALLOC, component, module, line);	if (ACPI_FAILURE (status)) {		acpi_os_free (address);		return_PTR (NULL);	}	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));	return_PTR ((void *) &address->user_space);}/******************************************************************************* * * FUNCTION:    Acpi_ut_free * * PARAMETERS:  Address             - Address of the memory to deallocate *              Component           - Component type of caller *              Module              - Source file name of caller *              Line                - Line number of caller * * RETURN:      None * * DESCRIPTION: Frees the memory at Address * ******************************************************************************/voidacpi_ut_free (	void                    *address,	u32                     component,	NATIVE_CHAR             *module,	u32                     line){	acpi_debug_mem_block    *debug_block;	FUNCTION_TRACE_PTR ("Ut_free", address);	if (NULL == address) {		_REPORT_ERROR (module, line, component,			("Acpi_ut_free: Trying to delete a NULL address\n"));		return_VOID;	}	debug_block = (acpi_debug_mem_block *)			  (((char *) address) - sizeof (acpi_debug_mem_header));	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++;	acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size;	acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block,			component, module, line);	acpi_os_free (debug_block);	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", address));	return_VOID;}#endif  /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -