summaryrefslogtreecommitdiff
path: root/exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h')
-rw-r--r--exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h b/exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h
new file mode 100644
index 0000000..3a5d12f
--- /dev/null
+++ b/exploits/7350855-netkit/netkit-telnet-0.16/telnet/ptrarray.h
@@ -0,0 +1,92 @@
1//
2// File: ptrarray.h
3// Date: 16-Jul-95
4// Description: Array of pointers
5//
6/*
7 * Copyright (c) 1995 David A. Holland.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the Author nor the names of any contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifndef PTRARRAY_H
36#define PTRARRAY_H
37
38#ifndef assert
39#include <assert.h>
40#endif
41
42#ifndef NULL
43#define NULL 0
44#endif
45
46template <class T>
47class ptrarray {
48 protected:
49 T **v;
50 int n, max;
51 void reallocto(int x) {
52 while (max<x) max += 16;
53 T **q = new T* [max];
54 for (int i=0; i<n; i++) q[i] = v[i];
55 delete []v;
56 v = q;
57 }
58 public:
59 ptrarray() { v=NULL; n=max=0; }
60 ~ptrarray() { delete []v; }
61
62 int num() const { return n; }
63
64 void setsize(int newsize) {
65 if (newsize>max) reallocto(newsize);
66 if (newsize>n) {
67 for (int i=n; i<newsize; i++) v[i] = NULL;
68 }
69 else {
70 // do nothing
71 }
72 n = newsize;
73 }
74
75 T *&operator [] (int ix) const {
76 assert(ix>=0 && ix<n);
77 return v[ix];
78 }
79
80 int add(T *val) {
81 int ix = n;
82 setsize(n+1);
83 v[ix] = val;
84 return ix;
85 }
86
87 void push(T *val) { add(val); }
88
89 void pop() { setsize(n-1); }
90};
91
92#endif