Re: Malloc()
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.
References: | |
| >Malloc() (From: Jason Moore <email@hidden>) |