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

📄 malloc.c

📁 minimal python variant for small footprint apps like embedded apps
💻 C
字号:
#include "config.h"#include <stdlib.h>#include <PalmOS.h>#include <PalmCompatibility.h>#include "libc_segments.h"#include <stdio.h>long malloc_ref_count = 0;long bytes_allocated = 0;long bytes_deallocated = 0;static HostFILE *hostfile = NULL;void dump_to_host(char *which, void *address, long value){	if (hostfile == NULL) {		hostfile = HostFOpen("malloc_dump.log", "w");		if (hostfile == NULL){			printf("problem opening log file\n");			return;		}	}	HostFPrintF(hostfile, "('%s', (%p, %ld))\n", which, address, value);       	HostFFlush (hostfile);}#ifndef USE_DLMALLOCvoid *malloc( size_t size ) {	void *mem = MemPtrNew(size);	if (mem == NULL)	     return NULL;	bytes_allocated += size;	malloc_ref_count++;	DUMP_TO_HOST("a", mem, size);		return mem;}#endiflong get_malloc_ref_count() SEG_LIBC;long get_malloc_ref_count() {	/* for debugging */	return malloc_ref_count;}#ifndef USE_DLMALLOCvoid get_allocations(long *allocated, long *deallocated){	if (allocated != NULL)		*allocated = bytes_allocated;	if (deallocated != NULL)		*deallocated = bytes_deallocated;}#endif

⌨️ 快捷键说明

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