Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
home /
gautam22188@iiitd.edu.in /
miniconda3 /
include /
[ HOME SHELL ]
Name
Size
Permission
Action
GL
[ DIR ]
drwxr-xr-x
X11
[ DIR ]
drwxr-xr-x
curl
[ DIR ]
drwxr-xr-x
dbus-1.0
[ DIR ]
drwxr-xr-x
fmt
[ DIR ]
drwxr-xr-x
gmock
[ DIR ]
drwxr-xr-x
gtest
[ DIR ]
drwxr-xr-x
libxml2
[ DIR ]
drwxr-xr-x
lzma
[ DIR ]
drwxr-xr-x
mamba
[ DIR ]
drwxr-xr-x
ncurses
[ DIR ]
drwxr-xr-x
ncursesw
[ DIR ]
drwxr-xr-x
nghttp2
[ DIR ]
drwxr-xr-x
nlohmann
[ DIR ]
drwxr-xr-x
openssl
[ DIR ]
drwxr-xr-x
python3.13
[ DIR ]
drwxr-xr-x
readline
[ DIR ]
drwxr-xr-x
reproc
[ DIR ]
drwxr-xr-x
reproc++
[ DIR ]
drwxr-xr-x
solv
[ DIR ]
drwxr-xr-x
textstyle
[ DIR ]
drwxr-xr-x
tl
[ DIR ]
drwxr-xr-x
unicode
[ DIR ]
drwxr-xr-x
unistring
[ DIR ]
drwxr-xr-x
uuid
[ DIR ]
drwxr-xr-x
xcb
[ DIR ]
drwxr-xr-x
yaml-cpp
[ DIR ]
drwxr-xr-x
archive.h
54.78
KB
-rw-r--r--
archive_entry.h
34.6
KB
-rw-r--r--
ares.h
46.85
KB
-rw-r--r--
ares_build.h
1.07
KB
-rw-r--r--
ares_dns.h
5.67
KB
-rw-r--r--
ares_dns_record.h
46.57
KB
-rw-r--r--
ares_nameser.h
13.05
KB
-rw-r--r--
ares_version.h
1.86
KB
-rw-r--r--
autosprintf.h
2.36
KB
-rw-r--r--
bzlib.h
6.09
KB
-rw-r--r--
curses.h
98.88
KB
-rw-r--r--
cursesapp.h
7.06
KB
-rw-r--r--
cursesf.h
27.57
KB
-rw-r--r--
cursesm.h
19.53
KB
-rw-r--r--
cursesp.h
8.61
KB
-rw-r--r--
cursesw.h
49.23
KB
-rw-r--r--
cursslk.h
7.16
KB
-rw-r--r--
default.h
581
B
-rw-r--r--
eti.h
2.9
KB
-rw-r--r--
etip.h
9.91
KB
-rw-r--r--
ev++.h
20.07
KB
-rw-r--r--
ev.h
29.55
KB
-rw-r--r--
expat.h
43.68
KB
-rw-r--r--
expat_config.h
3.28
KB
-rw-r--r--
expat_external.h
6.03
KB
-rw-r--r--
fakemysql.h
8.73
KB
-rw-r--r--
fakepq.h
1.16
KB
-rw-r--r--
fakesql.h
6.37
KB
-rw-r--r--
ffi.h
13.95
KB
-rw-r--r--
ffitarget.h
4.81
KB
-rw-r--r--
form.h
18.47
KB
-rw-r--r--
gettext-po.h
15.18
KB
-rw-r--r--
iconv.h
9.03
KB
-rw-r--r--
idn2.h
13.86
KB
-rw-r--r--
itcl.h
5.53
KB
-rw-r--r--
itcl2TclOO.h
1.76
KB
-rw-r--r--
itclDecls.h
6.86
KB
-rw-r--r--
itclInt.h
36.19
KB
-rw-r--r--
itclIntDecls.h
41.75
KB
-rw-r--r--
itclMigrate2TclCore.h
2.85
KB
-rw-r--r--
itclTclIntStubsFcn.h
1.68
KB
-rw-r--r--
jansson.h
15.95
KB
-rw-r--r--
jansson_config.h
1.59
KB
-rw-r--r--
ks_names.h
44.85
KB
-rw-r--r--
libcharset.h
1.48
KB
-rw-r--r--
libssh2.h
59.24
KB
-rw-r--r--
libssh2_publickey.h
4.83
KB
-rw-r--r--
libssh2_sftp.h
16.96
KB
-rw-r--r--
localcharset.h
5.92
KB
-rw-r--r--
lz4.h
42.25
KB
-rw-r--r--
lz4frame.h
31.98
KB
-rw-r--r--
lz4frame_static.h
2
KB
-rw-r--r--
lz4hc.h
19.71
KB
-rw-r--r--
lzma.h
9.56
KB
-rw-r--r--
menu.h
11.61
KB
-rw-r--r--
mysqlStubs.h
5.52
KB
-rw-r--r--
ncurses.h
98.88
KB
-rw-r--r--
ncurses_dll.h
4.08
KB
-rw-r--r--
odbcStubs.h
5.06
KB
-rw-r--r--
panel.h
4.42
KB
-rw-r--r--
pcre2.h
50.11
KB
-rw-r--r--
pcre2posix.h
7.18
KB
-rw-r--r--
pqStubs.h
3.5
KB
-rw-r--r--
simdjson.h
4.81
MB
-rw-r--r--
sqlite3.h
656.05
KB
-rw-r--r--
sqlite3ext.h
37.73
KB
-rw-r--r--
tcl.h
92.03
KB
-rw-r--r--
tclDecls.h
171.28
KB
-rw-r--r--
tclInt.h
170.46
KB
-rw-r--r--
tclIntDecls.h
55.63
KB
-rw-r--r--
tclIntPlatDecls.h
22.71
KB
-rw-r--r--
tclOO.h
4.16
KB
-rw-r--r--
tclOODecls.h
9.45
KB
-rw-r--r--
tclOOInt.h
23.6
KB
-rw-r--r--
tclOOIntDecls.h
7.01
KB
-rw-r--r--
tclPlatDecls.h
4
KB
-rw-r--r--
tclPort.h
1.17
KB
-rw-r--r--
tclThread.h
821
B
-rw-r--r--
tclTomMath.h
30.19
KB
-rw-r--r--
tclTomMathDecls.h
26.77
KB
-rw-r--r--
tclUnixPort.h
20.22
KB
-rw-r--r--
tdbc.h
1.62
KB
-rw-r--r--
tdbcDecls.h
1.46
KB
-rw-r--r--
tdbcInt.h
1.24
KB
-rw-r--r--
term.h
40.88
KB
-rw-r--r--
term_entry.h
8.46
KB
-rw-r--r--
termcap.h
3.4
KB
-rw-r--r--
test_data.hpp
85
B
-rw-r--r--
textstyle.h
22.28
KB
-rw-r--r--
tk.h
57.28
KB
-rw-r--r--
tk3d.h
3.04
KB
-rw-r--r--
tkArray.h
18
KB
-rw-r--r--
tkBusy.h
1.58
KB
-rw-r--r--
tkButton.h
12.2
KB
-rw-r--r--
tkCanvas.h
11.22
KB
-rw-r--r--
tkColor.h
2.59
KB
-rw-r--r--
tkDList.h
16.36
KB
-rw-r--r--
tkDecls.h
76.03
KB
-rw-r--r--
tkEntry.h
10.97
KB
-rw-r--r--
tkFileFilter.h
2.51
KB
-rw-r--r--
tkFont.h
7.82
KB
-rw-r--r--
tkImgPhoto.h
8.83
KB
-rw-r--r--
tkInt.h
47.1
KB
-rw-r--r--
tkIntDecls.h
49.86
KB
-rw-r--r--
tkIntPlatDecls.h
29.12
KB
-rw-r--r--
tkIntXlibDecls.h
66.76
KB
-rw-r--r--
tkMacOSX.h
1016
B
-rw-r--r--
tkMacOSXColor.h
16.71
KB
-rw-r--r--
tkMacOSXConstants.h
5.08
KB
-rw-r--r--
tkMacOSXCursors.h
4.21
KB
-rw-r--r--
tkMacOSXDebug.h
952
B
-rw-r--r--
tkMacOSXDefault.h
18.11
KB
-rw-r--r--
tkMacOSXEvent.h
527
B
-rw-r--r--
tkMacOSXFont.h
797
B
-rw-r--r--
tkMacOSXInt.h
4.83
KB
-rw-r--r--
tkMacOSXKeysyms.h
48.87
KB
-rw-r--r--
tkMacOSXPort.h
4.76
KB
-rw-r--r--
tkMacOSXPrivate.h
18.39
KB
-rw-r--r--
tkMacOSXWm.h
10.01
KB
-rw-r--r--
tkMacOSXXCursors.h
36.92
KB
-rw-r--r--
tkMenu.h
20.73
KB
-rw-r--r--
tkMenubutton.h
7.85
KB
-rw-r--r--
tkPlatDecls.h
6.67
KB
-rw-r--r--
tkPort.h
632
B
-rw-r--r--
tkScale.h
8.81
KB
-rw-r--r--
tkScrollbar.h
6.7
KB
-rw-r--r--
tkSelect.h
6.61
KB
-rw-r--r--
tkText.h
45.98
KB
-rw-r--r--
tkUndo.h
3.59
KB
-rw-r--r--
tkUnixDefault.h
16.95
KB
-rw-r--r--
tkUnixInt.h
674
B
-rw-r--r--
tkUnixPort.h
4.11
KB
-rw-r--r--
tkUuid.h
92
B
-rw-r--r--
unctrl.h
3.11
KB
-rw-r--r--
unicase.h
20.36
KB
-rw-r--r--
uniconv.h
7.36
KB
-rw-r--r--
unictype.h
48.22
KB
-rw-r--r--
unigbrk.h
5.39
KB
-rw-r--r--
unilbrk.h
6.79
KB
-rw-r--r--
unimetadata.h
1.15
KB
-rw-r--r--
uniname.h
1.94
KB
-rw-r--r--
uninorm.h
10.64
KB
-rw-r--r--
unistdio.h
9.96
KB
-rw-r--r--
unistr.h
23.25
KB
-rw-r--r--
unitypes.h
2.26
KB
-rw-r--r--
uniwbrk.h
3.18
KB
-rw-r--r--
uniwidth.h
2.14
KB
-rw-r--r--
zconf.h
16.08
KB
-rw-r--r--
zdict.h
25.89
KB
-rw-r--r--
zlib.h
94.56
KB
-rw-r--r--
zstd.h
177.49
KB
-rw-r--r--
zstd_errors.h
4.18
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : tkArray.h
/* * tkArray.h -- * * An array is a sequence of items, stored in a contiguous memory region. * Random access to any item is very fast. New items can be either appended * or prepended. An array may be traversed in the forward or backward direction. * * Copyright (c) 2018-2019 Gregor Cramer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * Note that this file will not be included in header files, it is the purpose * of this file to be included in source files only. Thus we are not using the * prefix "Tk_" here for functions, because all the functions have private scope. */ /* * ------------------------------------------------------------------------------- * Use the array in the following way: * ------------------------------------------------------------------------------- * typedef struct { int key, value; } Pair; * TK_PTR_ARRAY_DEFINE(MyArray, Pair); * MyArray *arr = NULL; * if (MyArray_IsEmpty(arr)) { * MyArray_Append(&arr, MakePair(1, 2)); * MyArray_Append(&arr, MakePair(2, 3)); * for (i = 0; i < MyArray_Size(arr); ++i) { * Pair *p = MyArray_Get(arr, i); * printf("%d -> %d\n", p->key, p->value); * ckfree(p); * } * MyArray_Free(&arr); * assert(arr == NULL); * } * ------------------------------------------------------------------------------- * Or with aggregated elements: * ------------------------------------------------------------------------------- * typedef struct { int key, value; } Pair; * TK_ARRAY_DEFINE(MyArray, Pair); * Pair p1 = { 1, 2 }; * Pair p2 = { 2, 3 }; * MyArray *arr = NULL; * if (MyArray_IsEmpty(arr)) { * MyArray_Append(&arr, p1); * MyArray_Append(&arr, p2); * for (i = 0; i < MyArray_Size(arr); ++i) { * const Pair *p = MyArray_Get(arr, i); * printf("%d -> %d\n", p->key, p->value); * } * MyArray_Free(&arr); * assert(arr == NULL); * } * ------------------------------------------------------------------------------- */ /*************************************************************************/ /* * Two array types will be provided: * Use TK_ARRAY_DEFINE if your array is aggregating the elements. Use * TK_PTR_ARRAY_DEFINE if your array contains pointers to elements. But * in latter case the array is not responsible for the lifetime of the * elements. */ /*************************************************************************/ /* * Array_ElemSize: Returns the memory size for one array element. */ /*************************************************************************/ /* * Array_BufferSize: Returns the memory size for given number of elements. */ /*************************************************************************/ /* * Array_IsEmpty: Array is empty? */ /*************************************************************************/ /* * Array_Size: Number of elements in array. */ /*************************************************************************/ /* * Array_Capacity: Capacity of given array. This is the maximal number of * elements fitting into current array memory without resizing the buffer. */ /*************************************************************************/ /* * Array_SetSize: Set array size, new size must not exceed the capacity of * the array. This function has to be used with care when increasing the * array size. */ /*************************************************************************/ /* * Array_First: Returns position of first element in array. Given array * may be NULL. */ /*************************************************************************/ /* * Array_Last: Returns position after last element in array. Given array * may be empty. */ /*************************************************************************/ /* * Array_Front: Returns first element in array. Given array must not be * empty. */ /*************************************************************************/ /* * Array_Back: Returns last element in array. Given array must not be * empty. */ /*************************************************************************/ /* * Array_Resize: Resize buffer of array for given number of elements. The * array may grow or shrink. Note that this function is not initializing * the increased buffer. */ /*************************************************************************/ /* * Array_ResizeAndClear: Resize buffer of array for given number of * elements. The array may grow or shrink. The increased memory will be * filled with zeroes. */ /*************************************************************************/ /* * Array_Clear: Fill specified range with zeroes. */ /*************************************************************************/ /* * Array_Free: Resize array to size zero. This function will release the * array buffer. */ /*************************************************************************/ /* * Array_Append: Insert given element after end of array. */ /*************************************************************************/ /* * Array_PopBack: Shrink array by one element. Given array must not be * empty. */ /*************************************************************************/ /* * Array_Get: Random access to array element at given position. The given * index must not exceed current array size. */ /*************************************************************************/ /* * Array_Set: Replace array element at given position with new value. The * given index must not exceed current array size. */ /*************************************************************************/ /* * Array_Find: Return index position of element which matches given * argument. If not found then -1 will be returned. */ /*************************************************************************/ #ifndef TK_ARRAY_DEFINED #define TK_ARRAY_DEFINED #include "tkInt.h" #if defined(__GNUC__) || defined(__clang__) # define __TK_ARRAY_UNUSED __attribute__((unused)) #else # define __TK_ARRAY_UNUSED #endif #define TK_ARRAY_DEFINE(AT, ElemType) /* AT = type of array */ \ /* ------------------------------------------------------------------------- */ \ typedef struct AT { \ size_t size; \ size_t capacity; \ ElemType buf[1]; \ } AT; \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Init(AT *arr) \ { \ assert(arr); \ arr->size = 0; \ arr->capacity = 0; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_ElemSize(void) \ { \ return sizeof(ElemType); \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_BufferSize(size_t numElems) \ { \ return numElems*sizeof(ElemType); \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_IsEmpty(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return !arr || arr->size == 0u; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_Size(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->size : 0u; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_Capacity(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->capacity : 0u; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_First(AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->buf : NULL; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Last(AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->buf + arr->size : NULL; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Front(AT *arr) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(!AT##_IsEmpty(arr)); \ return &arr->buf[0]; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Back(AT *arr) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(!AT##_IsEmpty(arr)); \ return &arr->buf[arr->size - 1]; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Resize(AT **arrp, size_t newSize) \ { \ assert(arrp); \ assert(!*arrp || (*arrp)->size != 0xdeadbeef); \ if (newSize == 0) { \ assert(!*arrp || ((*arrp)->size = 0xdeadbeef)); \ ckfree(*arrp); \ *arrp = NULL; \ } else { \ int init = *arrp == NULL; \ size_t memSize = AT##_BufferSize(newSize - 1) + sizeof(AT); \ *arrp = (AT *)ckrealloc(*arrp, memSize); \ if (init) { \ (*arrp)->size = 0; \ } else if (newSize < (*arrp)->size) { \ (*arrp)->size = newSize; \ } \ (*arrp)->capacity = newSize; \ } \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Clear(AT *arr, size_t from, size_t to) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(to <= AT##_Capacity(arr)); \ assert(from <= to); \ memset(arr->buf + from, 0, AT##_BufferSize(to - from)); \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_ResizeAndClear(AT **arrp, size_t newSize) \ { \ size_t oldCapacity; \ assert(arrp); \ oldCapacity = *arrp ? (*arrp)->capacity : 0; \ AT##_Resize(arrp, newSize); \ if (newSize > oldCapacity) { \ AT##_Clear(*arrp, oldCapacity, newSize); \ } \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_SetSize(AT *arr, size_t newSize) \ { \ assert(newSize <= AT##_Capacity(arr)); \ assert(!arr || arr->size != 0xdeadbeef); \ if (arr) { \ arr->size = newSize; \ } \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Append(AT **arrp, ElemType *elem) \ { \ assert(arrp); \ if (!*arrp) { \ AT##_Resize(arrp, 1); \ } else if ((*arrp)->size == (*arrp)->capacity) { \ AT##_Resize(arrp, (*arrp)->capacity + ((*arrp)->capacity + 1)/2); \ } \ (*arrp)->buf[(*arrp)->size++] = *elem; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_PopBack(AT *arr) \ { \ assert(!AT##_IsEmpty(arr)); \ return arr->size -= 1; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Get(const AT *arr, size_t at) \ { \ assert(arr); \ assert(at < AT##_Size(arr)); \ return (ElemType *) &arr->buf[at]; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Set(AT *arr, size_t at, ElemType *elem) \ { \ assert(arr); \ assert(at < AT##_Size(arr)); \ arr->buf[at] = *elem; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Free(AT **arrp) \ { \ AT##_Resize(arrp, 0); \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_Find(const AT *arr, const ElemType *elem) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ if (arr) { \ const ElemType *buf = arr->buf; \ size_t i; \ for (i = 0; i < arr->size; ++i) { \ if (memcmp(&buf[i], elem, sizeof(ElemType)) == 0) { \ return (int) i; \ } \ } \ } \ return -1; \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_Contains(const AT *arr, const ElemType *elem) \ { \ return AT##_Find(arr, elem) != -1; \ } \ /* ------------------------------------------------------------------------- */ #define TK_PTR_ARRAY_DEFINE(AT, ElemType) /* AT = type of array */ \ /* ------------------------------------------------------------------------- */ \ typedef struct AT { \ size_t size; \ size_t capacity; \ ElemType *buf[1]; \ } AT; \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_ElemSize(void) \ { \ return sizeof(ElemType); \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_BufferSize(size_t numElems) \ { \ return numElems*sizeof(ElemType *); \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_IsEmpty(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return !arr || arr->size == 0; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType ** \ AT##_First(AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->buf : NULL; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType ** \ AT##_Last(AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->buf + arr->size : NULL; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Front(AT *arr) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(!AT##_IsEmpty(arr)); \ return arr->buf[0]; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Back(AT *arr) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(!AT##_IsEmpty(arr)); \ return arr->buf[arr->size - 1]; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_Size(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->size : 0; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_Capacity(const AT *arr) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ return arr ? arr->capacity : 0; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Resize(AT **arrp, size_t newCapacity) \ { \ assert(arrp); \ assert(!*arrp || (*arrp)->size != 0xdeadbeef); \ if (newCapacity == 0) { \ assert(!*arrp || ((*arrp)->size = 0xdeadbeef)); \ ckfree(*arrp); \ *arrp = NULL; \ } else { \ int init = *arrp == NULL; \ size_t memSize = AT##_BufferSize(newCapacity - 1) + sizeof(AT); \ *arrp = (AT *)ckrealloc(*arrp, memSize); \ if (init) { \ (*arrp)->size = 0; \ } else if (newCapacity < (*arrp)->size) { \ (*arrp)->size = newCapacity; \ } \ (*arrp)->capacity = newCapacity; \ } \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Clear(AT *arr, size_t from, size_t to) \ { \ assert(arr); \ assert(arr->size != 0xdeadbeef); \ assert(to <= AT##_Capacity(arr)); \ assert(from <= to); \ memset(arr->buf + from, 0, AT##_BufferSize(to - from)); \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_ResizeAndClear(AT **arrp, size_t newCapacity) \ { \ size_t oldCapacity; \ assert(arrp); \ oldCapacity = *arrp ? (*arrp)->capacity : 0; \ AT##_Resize(arrp, newCapacity); \ if (newCapacity > oldCapacity) { \ AT##_Clear(*arrp, oldCapacity, newCapacity); \ } \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_SetSize(AT *arr, size_t newSize) \ { \ assert(arr); \ assert(newSize <= AT##_Capacity(arr)); \ arr->size = newSize; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Append(AT **arrp, ElemType *elem) \ { \ assert(arrp); \ if (!*arrp) { \ AT##_Resize(arrp, 1); \ } else if ((*arrp)->size == (*arrp)->capacity) { \ AT##_Resize(arrp, (*arrp)->capacity + ((*arrp)->capacity + 1)/2); \ } \ (*arrp)->buf[(*arrp)->size++] = elem; \ } \ \ __TK_ARRAY_UNUSED \ static size_t \ AT##_PopBack(AT *arr) \ { \ assert(!AT##_IsEmpty(arr)); \ return arr->size -= 1; \ } \ \ __TK_ARRAY_UNUSED \ static ElemType * \ AT##_Get(const AT *arr, size_t at) \ { \ assert(arr); \ assert(at < AT##_Size(arr)); \ return arr->buf[at]; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Set(AT *arr, size_t at, ElemType *elem) \ { \ assert(arr); \ assert(at < AT##_Size(arr)); \ arr->buf[at] = elem; \ } \ \ __TK_ARRAY_UNUSED \ static void \ AT##_Free(AT **arrp) \ { \ AT##_Resize(arrp, 0); \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_Find(const AT *arr, const ElemType *elem) \ { \ assert(!arr || arr->size != 0xdeadbeef); \ if (arr) { \ ElemType *const *buf = arr->buf; \ size_t i; \ for (i = 0; i < arr->size; ++i) { \ if (buf[i] == elem) { \ return (int) i; \ } \ } \ } \ return -1; \ } \ \ __TK_ARRAY_UNUSED \ static int \ AT##_Contains(const AT *arr, const ElemType *elem) \ { \ return AT##_Find(arr, elem) != -1; \ } \ /* ------------------------------------------------------------------------- */ #endif /* TK_ARRAY_DEFINED */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 105 * End: * vi:set ts=8 sw=4: */
Close