bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

_FastMallocBuffer with gc=yes


From: James Knight
Subject: _FastMallocBuffer with gc=yes
Date: Fri, 10 May 2002 03:59:30 -0400

FastMallocBuffer should not be used when GC is enabled. Not only is it not necessary, right now it causes problems, as it directly calls into the autorelease pool, which, itself, is not used in GC applications, and should not be called. The attached patch makes _FastMallocBuffer(size) simply call GC_malloc(size) with GC enabled.

(this patch is against gnustep-base-1.3.2)

*** Source-orig/NSObject.m      Fri Apr  5 11:26:47 2002
--- Source/NSObject.m   Fri May 10 03:14:14 2002
***************
*** 52,60 ****
--- 52,62 ----
  extern BOOL __objc_responds_to(id, SEL);
  #endif

+ #if GS_WITH_GC == 0
  @class        _FastMallocBuffer;
  static Class  fastMallocClass;
  static unsigned       fastMallocOffset;
+ #endif

  static Class  NSConstantStringClass;

***************
*** 721,735 ****
        autorelease_class = [NSAutoreleasePool class];
        autorelease_sel = @selector(addObject:);
autorelease_imp = [autorelease_class methodForSelector: autorelease_sel];
-       fastMallocClass = [_FastMallocBuffer class];
  #if   GS_WITH_GC == 0
  #if   !defined(REFCNT_LOCAL)
        GSIMapInitWithZoneAndCapacity(&retain_counts,
        NSDefaultMallocZone(), 1024);
  #endif
        fastMallocOffset = fastMallocClass->instance_size % ALIGN;
- #else
-       fastMallocOffset = 0;
  #endif
        NSConstantStringClass = [NSString constantStringClass];
        GSBuildStrings();
--- 723,735 ----
        autorelease_class = [NSAutoreleasePool class];
        autorelease_sel = @selector(addObject:);
autorelease_imp = [autorelease_class methodForSelector: autorelease_sel];
  #if   GS_WITH_GC == 0
+       fastMallocClass = [_FastMallocBuffer class];
  #if   !defined(REFCNT_LOCAL)
        GSIMapInitWithZoneAndCapacity(&retain_counts,
        NSDefaultMallocZone(), 1024);
  #endif
        fastMallocOffset = fastMallocClass->instance_size % ALIGN;
  #endif
        NSConstantStringClass = [NSString constantStringClass];
        GSBuildStrings();
***************
*** 1579,1589 ****
--- 1579,1591 ----
  /*
   *    Stuff for temporary memory management.
   */
+ #if GS_WITH_GC == 0
  @interface    _FastMallocBuffer : NSObject
  @end

  @implementation       _FastMallocBuffer
  @end
+ #endif

  /*
* Function for giving us the fastest possible allocation of memory to
***************
*** 1592,1603 ****
--- 1594,1609 ----
  void *
  _fastMallocBuffer(unsigned size)
  {
+ #if GS_WITH_GC
+   return GC_malloc(size);
+ #else
    _FastMallocBuffer   *o;

    o = (_FastMallocBuffer*)NSAllocateObject(fastMallocClass,
        size + fastMallocOffset, NSDefaultMallocZone());
    (*autorelease_imp)(autorelease_class, autorelease_sel, o);
    return ((void*)&o[1])+fastMallocOffset;
+ #endif
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]