FROM : John C. Randolph
DATE : Tue Jan 22 22:35:59 2002
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
DATE : Tue Jan 22 22:35:59 2002
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
| Related mails | Author | Date |
|---|---|---|
| Michael P. Rogers | Jan 21, 23:18 | |
| John C. Randolph | Jan 21, 23:45 | |
| Andy | Jan 22, 04:46 | |
| Bob Savage | Jan 22, 05:22 | |
| Erik M. Buck | Jan 22, 05:25 | |
| Jeff Galyan | Jan 22, 10:58 | |
| Simon Stapleton | Jan 22, 11:54 | |
| Marcel Weiher | Jan 22, 13:17 | |
| Jeff Galyan | Jan 22, 18:26 | |
| Jeff Galyan | Jan 22, 19:57 | |
| John C. Randolph | Jan 22, 20:02 | |
| Jeff Galyan | Jan 22, 20:15 | |
| John C. Randolph | Jan 22, 20:42 | |
| Jeff Galyan | Jan 22, 20:47 | |
| John C. Randolph | Jan 22, 20:58 | |
| Ondra Cada | Jan 22, 21:11 | |
| Jeff Galyan | Jan 22, 21:30 | |
| Brian Webster | Jan 22, 21:33 | |
| Marcel Weiher | Jan 22, 21:42 | |
| Jeff Galyan | Jan 22, 21:46 | |
| Marcel Weiher | Jan 22, 21:51 | |
| Jeff Galyan | Jan 22, 21:59 | |
| Jeff Galyan | Jan 22, 22:04 | |
| Jeff Galyan | Jan 22, 22:19 | |
| Bob Savage | Jan 22, 22:21 | |
| Jeff Galyan | Jan 22, 22:30 | |
| Marcel Weiher | Jan 22, 22:35 | |
| Marcel Weiher | Jan 22, 22:35 | |
| John C. Randolph | Jan 22, 22:35 | |
| Jeff Galyan | Jan 22, 22:42 | |
| tom_waters | Jan 22, 22:45 | |
| John C. Randolph | Jan 22, 22:57 | |
| Jeff Galyan | Jan 22, 23:04 | |
| Jeff Galyan | Jan 22, 23:06 | |
| Ondra Cada | Jan 23, 00:06 | |
| Ondra Cada | Jan 23, 00:12 | |
| Ondra Cada | Jan 23, 00:18 | |
| Jeff Galyan | Jan 23, 00:19 | |
| Marcel Weiher | Jan 23, 00:37 | |
| Bob Savage | Jan 23, 02:03 | |
| Simon Stapleton | Jan 23, 11:23 | |
| Bob Savage | Jan 26, 01:49 | |
| Bob Savage | Jan 29, 03:58 | |
| jgo | Jan 30, 05:31 | |
| Bob Savage | Jan 30, 07:37 |






Cocoa mail archive

