141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard/* 241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** Copyright 2003-2010, VisualOn, Inc. 341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** 441050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** Licensed under the Apache License, Version 2.0 (the "License"); 541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** you may not use this file except in compliance with the License. 641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** You may obtain a copy of the License at 741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** 841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** http://www.apache.org/licenses/LICENSE-2.0 941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** 1041050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** Unless required by applicable law or agreed to in writing, software 1141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** distributed under the License is distributed on an "AS IS" BASIS, 1241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** See the License for the specific language governing permissions and 1441050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard ** limitations under the License. 1541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard */ 1641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard/******************************************************************************* 1741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard File: cmnMemory.c 1841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 1941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard Content: sample code for memory operator implementation 2041050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 2141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard*******************************************************************************/ 2241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard#include "cmnMemory.h" 2341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 24ea1b2a40def72caa03a40460bf04911b0d9b4d46Martin Storsjo#include <stdlib.h> 2541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard#include <string.h> 2641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 2741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard//VO_MEM_OPERATOR g_memOP; 2841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 2984333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber#define UNUSED(x) (void)(x) 3084333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 3141050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemAlloc (VO_S32 uID, VO_MEM_INFO * pMemInfo) 3241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 3384333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 3484333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 3541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard if (!pMemInfo) 3641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return VO_ERR_INVALID_ARG; 3741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 3841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard pMemInfo->VBuffer = malloc (pMemInfo->Size); 3941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 4041050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 4141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 4241050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemFree (VO_S32 uID, VO_PTR pMem) 4341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 4484333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 4584333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 4641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard free (pMem); 4741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 4841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 4941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 5041050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemSet (VO_S32 uID, VO_PTR pBuff, VO_U8 uValue, VO_U32 uSize) 5141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 5284333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 5384333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 5441050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard memset (pBuff, uValue, uSize); 5541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 5641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 5741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 5841050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemCopy (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize) 5941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 6084333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 6184333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 6241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard memcpy (pDest, pSource, uSize); 6341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 6441050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 6541050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 6641050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemCheck (VO_S32 uID, VO_PTR pBuffer, VO_U32 uSize) 6741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 6884333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 6984333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(pBuffer); 7084333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uSize); 7184333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 7241050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 7341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 7441050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 7541050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_S32 cmnMemCompare (VO_S32 uID, VO_PTR pBuffer1, VO_PTR pBuffer2, VO_U32 uSize) 7641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 7784333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 7884333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 7941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return memcmp(pBuffer1, pBuffer2, uSize); 8041050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 8141050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 8241050cdb033641ddf26831d9272c0930f7b40a2dMans RullgardVO_U32 cmnMemMove (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize) 8341050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard{ 8484333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber UNUSED(uID); 8584333e0475bc911adc16417f4ca327c975cf6c36Andreas Huber 8641050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard memmove (pDest, pSource, uSize); 8741050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard return 0; 8841050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard} 8941050cdb033641ddf26831d9272c0930f7b40a2dMans Rullgard 90