FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/temp_serializer.c
/* Utility function that returns the lowest index of the first entry in
 * *ENTRIES that points to a dir entry with a name equal or larger than NAME.
 * If an exact match has been found, *FOUND will be set to TRUE. COUNT is
 * the number of valid entries in ENTRIES.
 */
Utility function that returns the lowest index of the first entry in
*ENTRIES that points to a dir entry with a name equal or larger than NAME.
If an exact match has been found, *FOUND will be set to TRUE. COUNT is
the number of valid entries in ENTRIES.
Utility function that returns the lowest index of the first entry in * ENTRIES that points to a dir entry with a name equal or larger than NAME . If an exact match has been found * FOUND will be set to TRUE . COUNT is the number of valid entries in ENTRIES .
static apr_size_t
find_entry(svn_fs_dirent_t **entries,
           const char *name,
           apr_size_t count,
           svn_boolean_t *found)
{
  apr_size_t lower = 0;
  apr_size_t upper = count;
  apr_size_t middle;
  for (middle = upper / 2; lower < upper; middle = (upper + lower) / 2)
    {
      const svn_fs_dirent_t *entry =
          svn_temp_deserializer__ptr(entries, (const void *const *)&entries[middle]);
      const char* entry_name =
          svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name);
      int diff = strcmp(entry_name, name);
      if (diff < 0)
        lower = middle + 1;
      else
        upper = middle;
    }
  *found = FALSE;
  if (lower < count)
    {
      const svn_fs_dirent_t *entry =
          svn_temp_deserializer__ptr(entries, (const void *const *)&entries[lower]);
      const char* entry_name =
          svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name);
      if (strcmp(entry_name, name) == 0)
        *found = TRUE;
    }
  return lower;
}
static apr_size_t find_entry ( svn_fs_dirent_t * * entries , const char * name , apr_size_t count , svn_boolean_t * found ) { apr_size_t lower = 0 ; apr_size_t upper = count ; apr_size_t middle ; for ( middle = upper / 2 ; lower < upper ; middle = ( upper + lower ) / 2 ) { const svn_fs_dirent_t * entry = svn_temp_deserializer__ptr ( entries , ( const void * const * ) & entries [ middle ] ) ; const char * entry_name = svn_temp_deserializer__ptr ( entry , ( const void * const * ) & entry -> name ) ; int diff = strcmp ( entry_name , name ) ; if ( diff < 0 ) lower = middle + 1 ; else upper = middle ; } * found = FALSE ; if ( lower < count ) { const svn_fs_dirent_t * entry = svn_temp_deserializer__ptr ( entries , ( const void * const * ) & entries [ lower ] ) ; const char * entry_name = svn_temp_deserializer__ptr ( entry , ( const void * const * ) & entry -> name ) ; if ( strcmp ( entry_name , name ) == 0 ) * found = TRUE ; } return lower ; }
Utility function that returns the lowest index of the first entry in
 *ENTRIES that points to a dir entry with a name equal or larger than NAME.
Utility function that returns the lowest index of the first entry in * ENTRIES that points to a dir entry with a name equal or larger than NAME .
/* binary search for the desired entry by name */ /* check whether we actually found a match */