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

信息检索与抽取

开发平台:

Unix_Linux

  1. /* Memory allocation definitions 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. #ifndef __objc_malloc_h_INCLUDE_GNU
  20. #define __objc_malloc_h_INCLUDE_GNU
  21. /* I do this to make substituting Boehm's Garbage Collection easy. */
  22. extern void *(*objc_malloc)(size_t);
  23. extern void *(*objc_atomic_malloc)(size_t);
  24. extern void *(*objc_realloc)(void *, size_t);
  25. extern void *(*objc_calloc)(size_t, size_t);
  26. extern void (*objc_free)(void *);
  27. #define OBJC_MALLOC(VAR, TYPE, NUM) 
  28.    ((VAR) = (TYPE *) (*objc_malloc)((unsigned)(NUM)*sizeof(TYPE))) 
  29. #define OBJC_ATOMIC_MALLOC(VAR, TYPE, NUM) 
  30.    ((VAR) = (TYPE *) (*objc_atomic_malloc)((unsigned)(NUM)*sizeof(TYPE))) 
  31. #define OBJC_REALLOC(VAR, TYPE, NUM) 
  32.    ((VAR) = (TYPE *) (*objc_realloc)((VAR), (unsigned)(NUM)*sizeof(TYPE)))
  33. #define OBJC_CALLOC(VAR, TYPE, NUM) 
  34.    ((VAR) = (TYPE *) (*objc_calloc)((unsigned)(NUM), sizeof(TYPE)))
  35. #define OBJC_FREE(PTR) (*objc_free)((PTR))
  36. #endif /* __objc_malloc_h_INCLUDE_GNU */