home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / src / AOS / mempools.c < prev    next >
C/C++ Source or Header  |  1999-09-23  |  3KB  |  118 lines

  1. /*
  2.  * $Id: $
  3.  */
  4.  
  5. /*
  6.  * Mesa 3-D graphics library
  7.  * Version:  3.1
  8.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  9.  *
  10.  * This library is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU Library General Public
  12.  * License as published by the Free Software Foundation; either
  13.  * version 2 of the License, or (at your option) any later version.
  14.  *
  15.  * This library is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * Library General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU Library General Public
  21.  * License along with this library; if not, write to the Free
  22.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. #define    NO_CONTEXT_AVAILABLE
  26. #include <AOS/amigamesa.h>
  27.  
  28. /***************************************************************************************************************************/
  29. /* Subfunctions *********************************************************************************************************** */
  30. /***************************************************************************************************************************/
  31.  
  32. #if 0
  33. APTR Reallocate(struct MemHeader *freeList, APTR memoryBlock, ULONG byteSize, ULONG oldSize) {
  34. }
  35.  
  36. APTR ReallocMem(APTR memoryBlock, ULONG byteSize, ULONG oldSize, ULONG requirements) {
  37. }
  38.  
  39. APTR ReallocAbs(APTR location, ULONG byteSize, ULONG oldSize) {
  40. }
  41.  
  42. struct MemList *ReallocEntry(struct MemList *entry) {
  43. }
  44.  
  45. APTR ReallocVec(APTR memoryBlock, ULONG byteSize, ULONG requirements) {
  46. }
  47.  
  48. APTR ReallocPooled(APTR poolHeader, APTR memoryBlock, ULONG byteSize, ULONG oldSize) {
  49. }
  50.  
  51. APTR ReallocVecPooled(APTR poolHeader, APTR memoryBlock, ULONG byteSize) {
  52. }
  53. #endif
  54.  
  55. APTR AllocVecPooled(register APTR poolHeader __asm__("a0"), register ULONG byteSize __asm__("d0"))
  56. {
  57.   register ULONG *address;
  58.  
  59.   byteSize += 4;
  60.   if ((address = AllocPooled(poolHeader, byteSize)))
  61.     *address++ = byteSize;
  62.  
  63.   return (APTR)address;
  64. }
  65.  
  66. void FreeVecPooled(register APTR poolHeader __asm__("a0"), register ULONG *memory __asm__("a1"))
  67. {
  68.   register ULONG byteSize;
  69.  
  70.   if (poolHeader && memory) {
  71.     byteSize = *--memory;
  72.     FreePooled(poolHeader, memory, byteSize);
  73.   }
  74. }
  75.  
  76. /***************************************************************************************************************************/
  77.  
  78. #if 0
  79. #ifdef    REPLACE_ALLOC
  80. void *realloc(void *mem, size_t newlen) {
  81.   ULONG oldlen = ((ULONG *)mem)[-1];
  82.   ULONG *newmem = mem;
  83.  
  84.   if (newlen != oldlen) {
  85. #if 0
  86.     /* heavy style, but should work */
  87.     if (newlen < oldlen)
  88.       FreePooled(amesaPool, (unsigned char *)mem + newlen, oldlen - newlen);
  89.     else
  90. #endif
  91.     if ((newmem = AllocVecPooled(amesaPool, newlen))) {
  92.       CopyMem(newmem, mem, oldlen);
  93.       FreeVecPooled(amesaPool, (ULONG *)mem);
  94.     }
  95.   }
  96.  
  97.   return newmem;
  98. }
  99.  
  100. void *calloc(size_t len, size_t cnt) {
  101.   void *ret;
  102.  
  103.   if ((ret = AllocVecPooled(amesaPool, len * cnt)))
  104.     bzero(ret, len * cnt);
  105.   
  106.   return ret;
  107. }
  108.  
  109. void *malloc(size_t len) {
  110.   return AllocVecPooled(amesaPool, len);
  111. }
  112.  
  113. void free(void *mem) {
  114.   FreeVecPooled(amesaPool, mem);
  115. }
  116. #endif
  117. #endif
  118.