Move buffer_is_binary() to xdiff-interface.h

We already have two instances where we want to determine if a buffer
contains binary data as opposed to text.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2007-06-05 03:36:11 +01:00
committed by Junio C Hamano
parent 20f1eb6b46
commit 6bfce93e04
4 changed files with 11 additions and 17 deletions

View File

@ -122,4 +122,12 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
return 0;
}
#define FIRST_FEW_BYTES 8000
int buffer_is_binary(const char *ptr, unsigned long size)
{
if (FIRST_FEW_BYTES < size)
size = FIRST_FEW_BYTES;
return !!memchr(ptr, 0, size);
}