title: Diff/compare two files by file descriptor (fd) instead of file name
body: <p>Is there any way in Linux, using <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a>, to generate a diff/patch of two files stored in memory, using a common format (ie: unified diff, like with the command-line <code>diff</code> utility)?</p>
  
  <p>I'm working on a system where I generate two text files in memory, and no external storage is available, or desired. I need to create a line-by-line diff of the two files, and since they are <code>mmap</code>'ed, they don't have file names, preventing me from simply calling <code>system("diff file1.txt file2.txt")</code>.</p>
  
  <p>I have file descriptors (<code>fd</code>s) available for use, and that's my only entry point to the data. Is there any way to generate a diff/patch by comparing the two open files? If the implementation is MIT/BSD licensed (ie: non-GPL), so much the better.</p>
  
  <p>Thank you.</p>