Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
kb_machblue_core_memory.c
Package: ST_5105DTV.rar [view]
Upload User: fy98168
Upload Date: 2015-06-26
Package Size: 13771k
Code Size: 4k
Category:
DVD
Development Platform:
C/C++
- //*****************************************************************************
- //File Name: kb_machblue_core_memory.c
- //
- //Description: memory function
- //
- // used by Machblue to access the platform's memory utility
- // used by Machblue to allocate memory from the platform
- // used by Machblue to allocate moveable memory blocks from
- //
- //Author: steven
- //
- //Date: 2006.12.29
- //
- //Version: v1.0
- //*****************************************************************************
- #include "string.h"
- #include "section.h"
- #include "osp.h"
- #include "machblue_defines.h"
- #include "machblue_customer.h"
- #include "machblue_porting_core.h"
- /**
- * Sets a memory block to a given pattern.
- * ptr < pointer to memory block to set >
- * pattern < pattern to set >
- * n < number of bytes to set >
- * @return none.
- */
- void mb_memset(void *ptr,int pattern,mb_size_t n)
- {
- memset(ptr, pattern,n);
- }
- /**
- * Moves n bytes from src to dest.
- * dest < destination to move bytes to >
- * src < source to move bytes from >
- * n < numbers of bytes to move >
- * @return none.
- */
- void mb_memmove(void *dest,const void *src,mb_size_t n)
- {
- memmove(dest,src,n);
- }
- /**
- * Copies n bytes from src to dest.
- * dest < destination to copy bytes to >
- * src < source to copy bytes from >
- * n < numbers of bytes to copy >
- * @return none.
- */
- void mb_memcpy(void *dest,const void *src,mb_size_t n)
- {
- memcpy(dest, src,n);
- }
- /**
- * Compares n bytes from ptr1 against ptr2.
- * ptr1 < pointer to first memory block to compare >
- * ptr2 < pointer to second memory block to compare >
- * n < number of bytes to compare >
- * @return none.
- */
- int mb_memcmp(const void *ptr1,const void *ptr2,mb_size_t n)
- {
- return memcmp(ptr1, ptr2,n);
- }
- /**
- * Allocates a memory chunk from the system heap. This function will only be called
- * if Machblue's heap is initialized as growable.
- * size < size to allocate in bytes >
- * @return an aligned pointer to the allocated memory chunk on success or NULL on failure.
- */
- void *mb_malloc(mb_size_t size)
- {
- void *p;
- if(size<=0)
- return NULL;
- p=KB_OSPMalloc(size);
- if(p==NULL)
- mb_printf("n[Machblue]:Memory malloc error[%ld].",size);
- else
- mb_memset(p,0xFF,size);
- return p;
- }
- /**
- * Deletes a previously allocated memory chunk.
- * ptr < previously allocated memory chunk to free >
- * @return none.
- */
- void mb_free(void *ptr)
- {
- KB_OSPFree(ptr);
- }
- /**
- * Allocates a movable memory block from the system heap.
- * On systems that do not support movable memory blocks, MB_FAILURE
- * should be returned. This function will only be called if Machblue's heap
- * is initialized as growable.
- * size < size to allocate in bytes >
- * mem_block < pointer to mem block to allocate >
- * @return MB_SUCCESS and updates "mem_block" on success or MB_FAILURE on failure.
- */
- mb_error_t mb_mem_block_alloc(mb_size_t size,mb_mem_block_t *mem_block)
- {
- if(mem_block == NULL)
- {
- return MB_FAILURE ;
- }
- *mem_block = (mb_mem_block_t)mb_malloc(size);
- if(*mem_block == 0)
- {
- return MB_FAILURE ;
- }
- return MB_SUCCESS ;
- }
- /**
- * Deletes a previously allocated memory block.
- * mem_block < previously allocated memory block handle to free >
- * @return none.
- */
- void mb_mem_block_free(mb_mem_block_t mem_block)
- {
- mb_free((void *)mem_block);
- }
- /**
- * Locks (pins) a memory block in memory.
- * mem_block < memory block handle to lock >
- * locked_ptr < pointer to location to store pointer to locked memory block >
- * @return MB_SUCCESS and sets locked_prt to an aligned pointer to the
- * allocated memory block on success, MB_FAILURE on failure.
- */
- mb_error_t mb_mem_block_lock(mb_mem_block_t mem_block,void **locked_ptr)
- {
- *locked_ptr=(void *)mem_block;
- return MB_SUCCESS ;
- }
- /**
- * Unlocks (unpins) a memory block
- * mem_block < memory block handle to unlock >
- * @return none.
- */
- void mb_mem_block_unlock(mb_mem_block_t mem_block)
- {
- }