nsCRT::memcpy(data->part_buffer + data->part_buffer_fp,
memcpy(data->part_buffer + data->part_buffer_fp,
MimePartBufferWrite (MimePartBufferData *data,					 const char *buf, PRInt32 size){  int status = 0;  NS_ASSERTION(data && buf && size > 0, "MimePartBufferWrite: Bad param");  if (!data || !buf || size <= 0)	return -1;  /* If we don't yet have a buffer (either memory or file) try and make a	 memory buffer.   */  if (!data->part_buffer &&	    !data->file_buffer_spec)	{	  int target_size = TARGET_MEMORY_BUFFER_SIZE;	  while (target_size > 0)		{		  data->part_buffer = (char *) PR_MALLOC(target_size);		  if (data->part_buffer) break;					/* got it! */		  target_size -= TARGET_MEMORY_BUFFER_QUANTUM;	/* decrease it and try														   again */		}	  if (data->part_buffer)		data->part_buffer_size = target_size;	  else		data->part_buffer_size = 0;	  data->part_buffer_fp = 0;	}  /* Ok, if at this point we still don't have either kind of buffer, try and	 make a file buffer. */  if (!data->part_buffer && !data->file_buffer_spec)	{    data->file_buffer_spec = nsMsgCreateTempFileSpec("nsma");		if (!data->file_buffer_spec)       return MIME_OUT_OF_MEMORY;    data->output_file_stream = new nsOutputFileStream(*(data->file_buffer_spec), PR_WRONLY | PR_CREATE_FILE, 00600);		if (!data->output_file_stream)     {			return MIME_UNABLE_TO_OPEN_TMP_FILE;		}  }  NS_ASSERTION(data->part_buffer || data->output_file_stream, "no part_buffer or file_stream");  /* If this buf will fit in the memory buffer, put it there.   */  if (data->part_buffer &&	  data->part_buffer_fp + size < data->part_buffer_size)	{	  nsCRT::memcpy(data->part_buffer + data->part_buffer_fp,				buf, size);	  data->part_buffer_fp += size;	}  /* Otherwise it won't fit; write it to the file instead. */  else	{	  /* If the file isn't open yet, open it, and dump the memory buffer		 to it. */	  if (!data->output_file_stream)		{		  if (!data->file_buffer_spec)  			data->file_buffer_spec = nsMsgCreateTempFileSpec("nsma");		  if (!data->file_buffer_spec)         return MIME_OUT_OF_MEMORY;      data->output_file_stream = new nsOutputFileStream(*(data->file_buffer_spec), PR_WRONLY | PR_CREATE_FILE, 00600);		  if (!data->output_file_stream)       {			  return MIME_UNABLE_TO_OPEN_TMP_FILE;		  }		  if (data->part_buffer && data->part_buffer_fp)			{			  status = data->output_file_stream->write(data->part_buffer,                                      					 data->part_buffer_fp);			  if (status < data->part_buffer_fp)           return MIME_OUT_OF_MEMORY;			}		  PR_FREEIF(data->part_buffer);		  data->part_buffer_fp = 0;		  data->part_buffer_size = 0;		}	  /* Dump this buf to the file. */	  status = data->output_file_stream->write (buf, size);	  if (status < size)       return MIME_OUT_OF_MEMORY;	}  return 0;}