This file is indexed.

/usr/include/handlersocket/string_buffer.hpp is in libhsclient-dev 1.0.6-97-g0986a75-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// vim:sw=2:ai

/*
 * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
 * See COPYRIGHT.txt for details.
 */

#ifndef DENA_STRING_BUFFER_HPP
#define DENA_STRING_BUFFER_HPP

#include <vector>
#include <stdlib.h>
#include <string.h>

#include "util.hpp"
#include "allocator.hpp"
#include "fatal.hpp"

namespace dena {

struct string_buffer : private noncopyable {
  string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { }
  ~string_buffer() {
    DENA_FREE(buffer);
  }
  const char *begin() const {
    return buffer + begin_offset;
  }
  const char *end() const {
    return buffer + end_offset;
  }
  char *begin() {
    return buffer + begin_offset;
  }
  char *end() {
    return buffer + end_offset;
  }
  size_t size() const {
    return end_offset - begin_offset;
  }
  void clear() {
    begin_offset = end_offset = 0;
  }
  void resize(size_t len) {
    if (size() < len) {
      reserve(len);
      memset(buffer + end_offset, 0, len - size());
    }
    end_offset = begin_offset + len;
  }
  void reserve(size_t len) {
    if (alloc_size >= begin_offset + len) {
      return;
    }
    size_t asz = alloc_size;
    while (asz < begin_offset + len) {
      if (asz == 0) {
	asz = 16;
      }
      const size_t asz_n = asz << 1;
      if (asz_n < asz) {
	fatal_abort("string_buffer::resize() overflow");
      }
      asz = asz_n;
    }
    void *const p = DENA_REALLOC(buffer, asz);
    if (p == 0) {
      fatal_abort("string_buffer::resize() realloc");
    }
    buffer = static_cast<char *>(p);
    alloc_size = asz;
  }
  void erase_front(size_t len) {
    if (len >= size()) {
      clear();
    } else {
      begin_offset += len;
    }
  }
  char *make_space(size_t len) {
    reserve(size() + len);
    return buffer + end_offset;
  }
  void space_wrote(size_t len) {
    len = std::min(len, alloc_size - end_offset);
    end_offset += len;
  }
  template <size_t N>
  void append_literal(const char (& str)[N]) {
    append(str, str + N - 1);
  }
  void append(const char *start, const char *finish) {
    const size_t len = finish - start;
    reserve(size() + len);
    memcpy(buffer + end_offset, start, len);
    end_offset += len;
  }
  void append_2(const char *s1, const char *f1, const char *s2,
    const char *f2) {
    const size_t l1 = f1 - s1;
    const size_t l2 = f2 - s2;
    reserve(end_offset + l1 + l2);
    memcpy(buffer + end_offset, s1, l1);
    memcpy(buffer + end_offset + l1, s2, l2);
    end_offset += l1 + l2;
  }
 private:
  char *buffer;
  size_t begin_offset;
  size_t end_offset;
  size_t alloc_size;
};

};

#endif