• 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: Malloc()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Malloc()


  • Subject: Re: Malloc()
  • From: Vince DeMarco <email@hidden>
  • Date: Tue, 2 Apr 2002 09:31:20 -0800

On Monday, April 1, 2002, at 10:49 PM, Jason Moore wrote:

Hello all.. Sorry to keep bothering everyone with C questions, but this one has me totally stumped..

I need to pass some data (in the form of a char* buffer) into a Unix library function. I'm getting my data from an NSData object using GetBytes:range:. My problem is that my buffers are not working.

i have:

char *buffer;
buffer = malloc(bufferSize);
NSLog(@"buffer size is: %i", sizeof(buffer));

here is where the problem is. the log output is 'buffer size is: 4', even when i change the malloc
statement to read buffer = malloc(129) (129 is the size of the buffer i need in my test case).

any ideas?


Try using malloc_size(buffer)

sizeof(buffer) will return the size of the buffer variable instead.

vince
_______________________________________________
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: Malloc()
      • From: Jim Correia <email@hidden>
    • Re: Malloc()
      • From: Jonathan Wight <email@hidden>
References: 
 >Malloc() (From: Jason Moore <email@hidden>)

  • Prev by Date: Re: NSLocalizedString
  • Next by Date: RE: NSLocalizedString
  • Previous by thread: Bundle patcher
  • Next by thread: Re: Malloc()
  • Index(es):
    • Date
    • Thread