objc-malloc.m
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:2k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /* Memory allocation support for Objective-C: easy garbage collection.
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.    Written by:  R. Andrew McCallum <mccallum@cs.rochester.edu>
  4.    Dept. of Computer Science, U. of Rochester, Rochester, NY  14627
  5.    This file is part of the GNU Objective-C Collection library.
  6.    This library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Library General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2 of the License, or (at your option) any later version.
  10.    
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Library General Public License for more details.
  15.    You should have received a copy of the GNU Library General Public
  16.    License along with this library; if not, write to the Free
  17.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */ 
  19. #include <misc.h>
  20. void*
  21. __objc_malloc(size_t size)
  22. {
  23.   return xmalloc (size);
  24. }
  25.  
  26. void*
  27. __objc_realloc(void* mem, size_t size)
  28. {
  29.   return xrealloc (mem, size);
  30. }
  31.  
  32. void*
  33. __objc_calloc(size_t nelem, size_t size)
  34. {
  35.   return xcalloc (nelem, size);
  36. }
  37. void
  38. __objc_free (void* obj)
  39. {
  40.   XFREE (obj);
  41. }
  42. /* I do this to make substituting Boehm's Garbage Collector easy. */
  43. void *(*objc_malloc)(size_t size) = __objc_malloc;
  44. void *(*objc_atomic_malloc)(size_t) = __objc_malloc;
  45. void *(*objc_realloc)(void *optr, size_t size) = __objc_realloc;
  46. void *(*objc_calloc)(size_t nelem, size_t size) = __objc_calloc;
  47. void (*objc_free)(void *optr) = __objc_free;