#
#
# add_file "vector.hh"
# content [d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66]
#
# patch "Makefile.am"
# from [2bbc5c3f98f24c81c68d2947f27e42cf012520a6]
# to [e02ee885d04cc7a04ab944830f39cff90b637d5a]
#
# patch "app_state.cc"
# from [d3bca41d60f83745111e44f868cf05847d4aaf8b]
# to [3bcb75b8497965bd13fc4762f1c1bf7c9fa44db3]
#
# patch "app_state.hh"
# from [c417b99837f0a2de58f1e8f9b059ab3d25f611c1]
# to [6f23fadcd338a7b5864a935fbcb6a44f661b178d]
#
# patch "asciik.hh"
# from [9822c026c2b57802ea1d1872670f017315151c78]
# to [b1c45a89506145446b33457ca62c836c9f255689]
#
# patch "automate.cc"
# from [f5e20383f535cdb67c487301422031aec585807d]
# to [9b2d2c6438d01423cde0615b3df1a753454bb506]
#
# patch "basic_io.hh"
# from [d843284e57239ab9616400b179882b56ffc5fcb1]
# to [9ad16beabaf2b1c272a356e8cf41bba97f7e1562]
#
# patch "cert.cc"
# from [a9e316071a5d773e6a7c0477f840889bc64073dd]
# to [4e4b08193ea8d1cafeebe2c1e227c0a70424062a]
#
# patch "cert.hh"
# from [0fb047d90d13c230b6d3a616052b294624718819]
# to [f34ca707b7e36e98331a580c2b411b65719e3116]
#
# patch "charset.cc"
# from [5f3f37f70f5bc3ef4a5f793a25f77a0aecdf81c0]
# to [b7b1395ae6b35e49c503ed858223ff54dbfbf161]
#
# patch "commands.hh"
# from [255a1ffe65f28f2a88c6526092f9a63c78ef11ac]
# to [18235ed79ea9bf22f0a6957e6bb7d2486b824db7]
#
# patch "cset.hh"
# from [c99e08758e5c07150b55364101f7c4ebb0b42c16]
# to [d76a7276730c9649ea326745abfd0d2be1c19a82]
#
# patch "cycle_detector.hh"
# from [82e82e8c4401a964bb405a97802c5f554774fad9]
# to [c8ee3bc84304bebe227f3fe2c3e43910cf8fbcbd]
#
# patch "database.cc"
# from [0a9272ee0e88d9e935871e8ab788a0f844695404]
# to [d7f4a2b811c26b90da6815f13249a18b1b3f4b9f]
#
# patch "database.hh"
# from [df490ba6c815f5afca05231b2e8077b917ef9e14]
# to [0cf5bf163523720b681afd1739903947c8d8af65]
#
# patch "diff_patch.cc"
# from [943b5d68699b7ae6e06c5f335d8445cb961dabff]
# to [329d20d3cb5f1a7b67ef62ce5583f919285f76d5]
#
# patch "diff_patch.hh"
# from [681984533e6cb27a293e72d159ec24457f7cf804]
# to [9035f2d57120bd8d9f6c70bf9702e87d1cb42d48]
#
# patch "enumerator.cc"
# from [81b5bcc7dbb9e02db1eec42411b681c33566e1b0]
# to [bbf94536322448b253ba46c2a679f658e2393c70]
#
# patch "enumerator.hh"
# from [8574278f53e06d0a6d1a80a6983f6ae04a0043f4]
# to [051909004ac5fdeed44714e2d49acb5e1af4fe48]
#
# patch "graph.hh"
# from [dfb30a026f9dcbb139d13d96eadc7ed591e09aaf]
# to [6384f6bd01b8b43383ba2e6adf6ae10b6f725bac]
#
# patch "key_store.hh"
# from [6dd1c25123305d42dfbf957f6ee872fae601e96b]
# to [44eedad6a981d25603d458c675187c0c740ce3d2]
#
# patch "lcs.cc"
# from [3e6a13b291a0d7cd12b700ad3c13fe5d527c841f]
# to [435ebb80d063b1036a962fea5f800784db804811]
#
# patch "lcs.hh"
# from [f69386c0998c472802d3cb7092d8aeea3d68bcaf]
# to [3b862f707ecadc59ea9204714fb2068bf8fec66c]
#
# patch "lua.cc"
# from [7bdc5718a8d1db646ab3093d05cb8faa65e4fd0e]
# to [cdff2c5d72b8deecf8d8f95fd9a1d82cdc73f077]
#
# patch "merkle_tree.hh"
# from [40e3ce0f83ba3a41bcca9a4896792d52627f0955]
# to [88d7a2e577684e0a283f4fd0cc2d634f8c2479b8]
#
# patch "netcmd.cc"
# from [eaf56a9400d6bc15eccb6114c19cc7ce5cde9622]
# to [584773446209355dabaaba6c8a88db4b06fb778c]
#
# patch "netcmd.hh"
# from [91da5034baab3bc9dec528c24ca5b8b2ff484d5c]
# to [8b17081341db6c09ae654998957b61c2d790edd2]
#
# patch "netxx_pipe.hh"
# from [a20357be17876b21d53d2bf237e0a0024d716018]
# to [873bc7d111d59db057cba5ea5f9ce31ad7608e1f]
#
# patch "option.hh"
# from [b84098e030a8b5982930a0d6c093958792d38f13]
# to [7b18a9e8807a29cd59fd8a9e727f89e82a694366]
#
# patch "options_list.hh"
# from [3d15836cb0ce2d42fef9e00d9c14f7f19a9868c2]
# to [eabdd6463a42ed5bbbedbadfceb42925f90e5c2a]
#
# patch "project.cc"
# from [bff2c8ff7455f6e988707c7cd7627ecf59f1a8c1]
# to [bc5f626244e7e3de2cd2e5b6bee4832201c52570]
#
# patch "randomfile.hh"
# from [10edb3699a38484b52912a8ef33cc937a0a9f520]
# to [b6b680a21c57b786686cedc7330d3ecbf847c924]
#
# patch "rcs_file.cc"
# from [73064ea1d3e228d0cd5c811973c492b4657e14a6]
# to [ff879adf81e7dd34604af8338e376b0692d1dcb6]
#
# patch "rcs_file.hh"
# from [1cc24800d1d2c57e32cc8e2fc89c5cbb3faa8a1f]
# to [4f97971ca41a02c642818bf4a6dda13010bbe28f]
#
# patch "rcs_import.cc"
# from [7e735462858d40848d763833eccc88f656ebb3ec]
# to [f6ce4f02b7f5e254f6be4e5e98739fce77b62947]
#
# patch "restrictions.cc"
# from [b1a0ddef5614aa652daa4d5e51fbe405e827e07d]
# to [0ed28c124d4af8fbaab01d6d8445980ca7d0bdc9]
#
# patch "roster.cc"
# from [cc0a1bbc54cef7ff0360cb9f48aed726d6fe1645]
# to [e36b1e83bf7a5a3538f0a882feaccb9f32250118]
#
# patch "sanity.cc"
# from [87ade97fa69cae5b9558e6358ceadfe172828e01]
# to [a25e5e09451b0ea2219c650a1a64502148ab5005]
#
# patch "sanity.hh"
# from [f66a2562e653712b305795333187b96343dec036]
# to [199cc212e369ac57a758556faf52d530565b54c6]
#
# patch "selectors.hh"
# from [83f7e51e0ae9c30864e8f39eeef0368ab1000315]
# to [a580067010375b01e72094ebc255e26da4894384]
#
# patch "simplestring_xform.hh"
# from [501041263b4eb2b04c61e753b5bc636276716040]
# to [0280d49b889bc0b7b2900d5d123cc8ec95a115eb]
#
# patch "smap.hh"
# from [bf9bd78d9e317a89f27f5cecaa0aafff8007b6b0]
# to [d47fcb8010470dbe063bab5c669547cf601e80fc]
#
# patch "ssh_agent.hh"
# from [13e3cf45bfa19a9f8832bd6cdcca502271bb8047]
# to [b5cf999ba112dc33279647aac778a458258f7e06]
#
# patch "transforms.cc"
# from [91ed3086b19a25d7d28258a984bcdd8a32a8a549]
# to [2a2510681a0dccdc471ef508dc51f5c568d58963]
#
# patch "ui.cc"
# from [4de898f353d62cc49f8cb22330527983f589277e]
# to [989194f7bb73d7cc55e7197508b9203dde9d164f]
#
# patch "ui.hh"
# from [ad79ebfa9e7e5935b75230d47e85684da844b30b]
# to [e2c82fd7f5fb014e3cacf951bb4a5c165c16d13b]
#
# patch "unit_tests.cc"
# from [1fac50797304ac4b4addf8b5153fd9dbb02863da]
# to [6c18091f527b9b38ae589bf9b6dede0896abdcd7]
#
# patch "update.cc"
# from [bc9c39135d1e082cf2c4dfbe425ef08e6013ffc4]
# to [974b6d54d36ef82389781738f2b247417d5def27]
#
# patch "xdelta.cc"
# from [3f540c8b573608425e174ded788c6597e8b77a1b]
# to [d17efefc2d804088f5dc02c888c5f4a8536d7e17]
#
============================================================
--- vector.hh d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66
+++ vector.hh d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66
@@ -0,0 +1,89 @@
+#ifndef __VECTOR_HH__
+#define __VECTOR_HH__
+
+// Copyright (C) 2002 Graydon Hoare
+//
+// This program is made available under the GNU GPL version 2.0 or
+// greater. See the accompanying file COPYING for details.
+//
+// This program is distributed WITHOUT ANY WARRANTY; without even the
+// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+// we're interested in trapping index overflows early and precisely,
+// because they usually represent *very significant* logic errors. we use
+// an inline template function because the idx(...) needs to be used as an
+// expression, not as a statement.
+
+// to ensure that our index checkers are always visible when std::vector
+// is in use, this header is the only file that should include ;
+// all others should include this file instead.
+
+#include
+#include "sanity.hh"
+#include "quick_alloc.hh" // to get the QA() macro
+
+template
+inline T & checked_index(std::vector & v,
+ typename std::vector::size_type i,
+ char const * vec,
+ char const * index,
+ char const * file,
+ int line)
+{
+ if (UNLIKELY(i >= v.size()))
+ global_sanity.index_failure(vec, index, v.size(), i, file, line);
+ return v[i];
+}
+
+template
+inline T const & checked_index(std::vector const & v,
+ typename std::vector::size_type i,
+ char const * vec,
+ char const * index,
+ char const * file,
+ int line)
+{
+ if (UNLIKELY(i >= v.size()))
+ global_sanity.index_failure(vec, index, v.size(), i, file, line);
+ return v[i];
+}
+
+#ifdef QA_SUPPORTED
+template
+inline T & checked_index(std::vector & v,
+ typename std::vector::size_type i,
+ char const * vec,
+ char const * index,
+ char const * file,
+ int line)
+{
+ if (UNLIKELY(i >= v.size()))
+ global_sanity.index_failure(vec, index, v.size(), i, file, line);
+ return v[i];
+}
+
+template
+inline T const & checked_index(std::vector const & v,
+ typename std::vector::size_type i,
+ char const * vec,
+ char const * index,
+ char const * file,
+ int line)
+{
+ if (UNLIKELY(i >= v.size()))
+ global_sanity.index_failure(vec, index, v.size(), i, file, line);
+ return v[i];
+}
+#endif // QA_SUPPORTED
+
+#define idx(v, i) checked_index((v), (i), #v, #i, __FILE__, __LINE__)
+
+// Local Variables:
+// mode: C++
+// c-file-style: "gnu"
+// indent-tabs-mode: nil
+// End:
+// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
+
+#endif // __VECTOR_HH__
============================================================
--- Makefile.am 2bbc5c3f98f24c81c68d2947f27e42cf012520a6
+++ Makefile.am e02ee885d04cc7a04ab944830f39cff90b637d5a
@@ -7,7 +7,7 @@ SANITY_CORE_SOURCES = \
cmd_othervcs.cc cmd_automate.cc cmd_files.cc
SANITY_CORE_SOURCES = \
- sanity.cc sanity.hh quick_alloc.hh base.hh \
+ sanity.cc sanity.hh quick_alloc.hh vector.hh base.hh \
simplestring_xform.cc simplestring_xform.hh \
constants.cc constants.hh numeric_vocab.hh \
platform.hh numeric_vocab.cc
============================================================
--- app_state.cc d3bca41d60f83745111e44f868cf05847d4aaf8b
+++ app_state.cc 3bcb75b8497965bd13fc4762f1c1bf7c9fa44db3
@@ -8,7 +8,7 @@
// PURPOSE.
#include "base.hh"
-#include
+#include "vector.hh"
#include "botan/pubkey.h"
#include "botan/rsa.h"
============================================================
--- app_state.hh c417b99837f0a2de58f1e8f9b059ab3d25f611c1
+++ app_state.hh 6f23fadcd338a7b5864a935fbcb6a44f661b178d
@@ -14,7 +14,7 @@ class lua_hooks;
class lua_hooks;
#include