I'm not sure that char buf[i] = malloc(size) makes any sense. What I would have thought you would do would be:

Code:
int length = 10, i=0;

char buf[length];

for(i=0; i<length; i++)
	buf[i] = malloc(size);
My code could be wrong because I'm not certain what you're trying to do. What you have written above says "create a character array of size 'i' and allocate size memory for it" (not sure about the last part). That doesn't really make too much sense. I would expect you to create an array first, then allocate sizes for the individual elements. But then again, I could be completely wrong because I'm not a hardcore c programmer

[edit]If that's not your problem, the other thing that I would suspect is that you're not accessing the buffer correctly. When I think about it now, I think what I said above was wrong. How are you attempting to write to the buffer? Are you getting a pointer to the buffer and then using it to access it? That's what you would need to do, I think.[/edit]

Hope that helps you,

ac