📄 main.c
字号:
/*
* Copyright (c) 1995,2000 TriMedia Technologies Inc.
*
* +------------------------------------------------------------------+
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such |
* | a license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided|
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
* Module name : main.c 1.3
*
* Last update : 11:17:49 - 00/06/19
*
* Description : Simple example of customizing dynamic
* loader memory managers.
*
*/
#include <tmlib/tmtypes.h>
#include <tmlib/DynamicLoader.h>
#include <stdio.h>
#include <stdlib.h>
void dll_function( int x );
static Pointer temp_malloc (UInt size)
{
Pointer result= malloc(size);
printf("*** Temp malloc of size= %d: 0x%08x\n", size, result);
return result;
}
static void temp_free (Pointer block)
{
printf("*** Temp free of 0x%08x\n", block);
free(block);
}
static Pointer perm_malloc (UInt size)
{
Pointer result= malloc(size);
printf("*** Perm malloc of size= %d: 0x%08x\n", size, result);
return result;
}
static void perm_free (Pointer block)
{
printf("*** Perm free of 0x%08x\n", block);
free(block);
}
void main()
{
Int i;
DynLoad_MallocFun tm= temp_malloc;
DynLoad_MallocFun pm= perm_malloc;
DynLoad_FreeFun tf= temp_free;
DynLoad_FreeFun pf= perm_free;
DynLoad_swap_mm( &pm, &pf, &tm, &tf );
for (i=0; i<10; i++) {
dll_function(i);
}
DynLoad_unload_dll( "lib.dll" );
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -