Coverage Report

Created: 2025-12-14 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/isc/region.c
Line
Count
Source
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
5
 *
6
 * This Source Code Form is subject to the terms of the Mozilla Public
7
 * License, v. 2.0. If a copy of the MPL was not distributed with this
8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9
 *
10
 * See the COPYRIGHT file distributed with this work for additional
11
 * information regarding copyright ownership.
12
 */
13
14
/*! \file */
15
16
#include <stdlib.h>
17
#include <string.h>
18
19
#include <isc/region.h>
20
#include <isc/util.h>
21
22
int
23
129M
isc_region_compare(isc_region_t *r1, isc_region_t *r2) {
24
129M
  unsigned int l;
25
129M
  int result;
26
27
129M
  REQUIRE(r1 != NULL);
28
129M
  REQUIRE(r2 != NULL);
29
129M
  REQUIRE(r1->base != NULL);
30
129M
  REQUIRE(r2->base != NULL);
31
32
129M
  l = (r1->length < r2->length) ? r1->length : r2->length;
33
34
129M
  if ((result = memcmp(r1->base, r2->base, l)) != 0) {
35
128M
    return (result < 0) ? -1 : 1;
36
128M
  } else {
37
828k
    return (r1->length == r2->length)  ? 0
38
828k
           : (r1->length < r2->length) ? -1
39
2.90k
               : 1;
40
828k
  }
41
129M
}