• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Initializing an Array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing an Array


  • Subject: Re: Initializing an Array
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 22 Jan 2002 13:35:59 -0800

On Tuesday, January 22, 2002, at 01:19 PM, Jeff Galyan wrote:
> Well, here's the rub: when I malloc or calloc something and
> then free it
> after use (in Cocoa, and after ensuring it's non-NULL), I get a
> segfault
> when the ObjC runtime tries to free it again.

Well, of course. If you want NSObject's -dealloc method to free
some memory, you shouldn't be doing it, too.

It sounds like your problem is a result of mixing malloc() with
+alloc. If you're allocating storage for an Obj-C instance,
don't use malloc(), use +alloc. If you want an
arbitrarily-sized block of bytes, try using NSData and
NSMutableData.

-jcr


"This is not a book to be tossed aside lightly. Rather, it
should be hurled with great force." -Dorothy Parker


  • Follow-Ups:
    • Re: Initializing an Array
      • From: Jeff Galyan <email@hidden>
References: 
 >Re: Initializing an Array (From: Jeff Galyan <email@hidden>)

  • Prev by Date: Re: Initializing an Array
  • Next by Date: Re: Question about movePath
  • Previous by thread: Re: Initializing an Array
  • Next by thread: Re: Initializing an Array
  • Index(es):
    • Date
    • Thread