• 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
NSMutableData doesn't support dataWithBytesNoCopy properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableData doesn't support dataWithBytesNoCopy properly


  • Subject: NSMutableData doesn't support dataWithBytesNoCopy properly
  • From: Simson Garfinkel <email@hidden>
  • Date: Sat, 16 Feb 2002 14:37:01 -0500

Here is my program:

#import <Cocoa/Cocoa.h>

int main()
{
NSMutableData *data;

id pool = [[NSAutoreleasePool alloc] init];

data = [NSMutableData dataWithBytesNoCopy:"12345" length:5];

NSLog(@"data=%@",data);
[pool release];
return 0;
}

Here are the results:

[simsong@localhost ~] 362 % ./x
*** malloc[2580]: Deallocation of a pointer not malloced: 0x1ee0; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
2002-02-16 14:30:10.191 x[2580] data=<31323334 35>
[simsong@localhost ~] 363 % %%


I set all of the Malloc Help variables and get this:

[simsong@localhost ~] 379 % ./x
malloc[2597]: protecting edges
malloc[2597]: enabling scribbling to detect mods to free blocks
malloc[2597]: checks heap after 1th operation and each 1000 operations
malloc[2597]: environment variables that can be set for debug:
- MallocGuardEdges to add 2 guard pages for each large block
- MallocDoNotProtectPrelude to disable protection (when previous flag set)
- MallocDoNotProtectPostlude to disable protection (when previous flag set)
- MallocStackLogging to record all stacks. Tools like leaks can then be applied
- MallocStackLoggingNoCompact to record all stacks. Needed for malloc_history
- MallocScribble to detect writing on free blocks: 0x55 is written upon free
- MallocCheckHeapStart <n> to check the heap from time to time after <n> operations
- MallocHelp - this help!
MallocCheckHeap: PASSED check at 1th operation
MallocCheckHeap: PASSED check at 1001th operation
MallocCheckHeap: PASSED check at 2001th operation
MallocCheckHeap: PASSED check at 3001th operation
MallocCheckHeap: PASSED check at 4001th operation
*** malloc[2597]: Deallocation of a pointer not malloced: 0x1ee0; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
MallocCheckHeap: PASSED check at 5001th operation
2002-02-16 14:35:11.752 x[2597] data=<31323334 35>
[simsong@localhost ~] 380 %


I would like NSMutableData to support dataWithBytesNoCopy properly, but I also want it to handle append properly. Has anybody else other encountered this?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: NSMutableData doesn't support dataWithBytesNoCopy properly
      • From: Marcel Weiher <email@hidden>
    • Re: NSMutableData doesn't support dataWithBytesNoCopy properly
      • From: Lance Bland <email@hidden>
  • Prev by Date: Re: Hiding and showing a window
  • Next by Date: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Previous by thread: Re: Hiding and showing a window
  • Next by thread: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Index(es):
    • Date
    • Thread