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
/
opt /
miniconda3 /
python /
include /
[ HOME SHELL ]
Name
Size
Permission
Action
curl
[ DIR ]
drwxrwxr-x
editline
[ DIR ]
drwxrwxr-x
fmt
[ DIR ]
drwxrwxr-x
gmock
[ DIR ]
drwxrwxr-x
gssapi
[ DIR ]
drwxrwxr-x
gssrpc
[ DIR ]
drwxrwxr-x
gtest
[ DIR ]
drwxrwxr-x
kadm5
[ DIR ]
drwxrwxr-x
krb5
[ DIR ]
drwxrwxr-x
libxml2
[ DIR ]
drwxrwxr-x
lzma
[ DIR ]
drwxrwxr-x
mamba
[ DIR ]
drwxrwxr-x
ncurses
[ DIR ]
drwxrwxr-x
ncursesw
[ DIR ]
drwxrwxr-x
nghttp2
[ DIR ]
drwxrwxr-x
openssl
[ DIR ]
drwxrwxr-x
python3.12
[ DIR ]
drwxrwxr-x
readline
[ DIR ]
drwxrwxr-x
reproc
[ DIR ]
drwxrwxr-x
reproc++
[ DIR ]
drwxrwxr-x
solv
[ DIR ]
drwxrwxr-x
unicode
[ DIR ]
drwxrwxr-x
uuid
[ DIR ]
drwxrwxr-x
yaml-cpp
[ DIR ]
drwxrwxr-x
archive.h
52.5
KB
-rw-rw-r--
archive_entry.h
33
KB
-rw-rw-r--
ares.h
26.07
KB
-rw-rw-r--
ares_build.h
1.01
KB
-rw-rw-r--
ares_dns.h
5.41
KB
-rw-rw-r--
ares_nameser.h
13.13
KB
-rw-rw-r--
ares_rules.h
4.17
KB
-rw-rw-r--
ares_version.h
648
B
-rw-rw-r--
bzlib.h
6.09
KB
-rw-rw-r--
com_err.h
1.93
KB
-rw-rw-r--
curses.h
97.9
KB
-rw-rw-r--
cursesapp.h
7.06
KB
-rw-rw-r--
cursesf.h
27.57
KB
-rw-rw-r--
cursesm.h
19.53
KB
-rw-rw-r--
cursesp.h
8.61
KB
-rw-rw-r--
cursesw.h
49.23
KB
-rw-rw-r--
cursslk.h
7.16
KB
-rw-rw-r--
default.h
581
B
-rw-rw-r--
eti.h
2.9
KB
-rw-rw-r--
etip.h
9.91
KB
-rw-rw-r--
ev++.h
20.07
KB
-rw-rw-r--
ev.h
29.55
KB
-rw-rw-r--
expat.h
43.04
KB
-rw-rw-r--
expat_config.h
4.16
KB
-rw-rw-r--
expat_external.h
5.89
KB
-rw-rw-r--
fakemysql.h
8.73
KB
-rw-rw-r--
fakepq.h
1.16
KB
-rw-rw-r--
fakesql.h
6.37
KB
-rw-rw-r--
ffi.h
13.95
KB
-rw-rw-r--
ffitarget.h
4.81
KB
-rw-rw-r--
form.h
18.47
KB
-rw-rw-r--
gssapi.h
181
B
-rw-rw-r--
histedit.h
9.41
KB
-rw-rw-r--
itcl.h
5.53
KB
-rw-rw-r--
itcl2TclOO.h
1.81
KB
-rw-rw-r--
itclDecls.h
6.86
KB
-rw-rw-r--
itclInt.h
36.22
KB
-rw-rw-r--
itclIntDecls.h
41.75
KB
-rw-rw-r--
itclMigrate2TclCore.h
2.85
KB
-rw-rw-r--
itclTclIntStubsFcn.h
1.68
KB
-rw-rw-r--
kdb.h
62.67
KB
-rw-rw-r--
krad.h
8.72
KB
-rw-rw-r--
krb5.h
402
B
-rw-rw-r--
ks_names.h
44.79
KB
-rw-rw-r--
libssh2.h
57.23
KB
-rw-rw-r--
libssh2_publickey.h
4.79
KB
-rw-rw-r--
libssh2_sftp.h
16.38
KB
-rw-rw-r--
lz4.h
42.25
KB
-rw-rw-r--
lz4frame.h
31.98
KB
-rw-rw-r--
lz4frame_static.h
2
KB
-rw-rw-r--
lz4hc.h
19.71
KB
-rw-rw-r--
lzma.h
9.73
KB
-rw-rw-r--
menu.h
11.61
KB
-rw-rw-r--
mysqlStubs.h
5.52
KB
-rw-rw-r--
nc_tparm.h
4.67
KB
-rw-rw-r--
ncurses.h
97.9
KB
-rw-rw-r--
ncurses_dll.h
3.95
KB
-rw-rw-r--
odbcStubs.h
5.06
KB
-rw-rw-r--
panel.h
4.42
KB
-rw-rw-r--
pcre2.h
46.15
KB
-rw-rw-r--
pcre2posix.h
7.12
KB
-rw-rw-r--
pqStubs.h
3.5
KB
-rw-rw-r--
profile.h
11.89
KB
-rw-rw-r--
sqlite3.h
626.84
KB
-rw-rw-r--
sqlite3ext.h
37.25
KB
-rw-rw-r--
tcl.h
91.69
KB
-rw-rw-r--
tclDecls.h
171.45
KB
-rw-rw-r--
tclInt.h
169.69
KB
-rw-rw-r--
tclIntDecls.h
55.63
KB
-rw-rw-r--
tclIntPlatDecls.h
22.71
KB
-rw-rw-r--
tclOO.h
4.16
KB
-rw-rw-r--
tclOODecls.h
9.45
KB
-rw-rw-r--
tclOOInt.h
23.08
KB
-rw-rw-r--
tclOOIntDecls.h
7.01
KB
-rw-rw-r--
tclPlatDecls.h
4
KB
-rw-rw-r--
tclPort.h
1.17
KB
-rw-rw-r--
tclThread.h
821
B
-rw-rw-r--
tclTomMath.h
29.76
KB
-rw-rw-r--
tclTomMathDecls.h
26.73
KB
-rw-rw-r--
tclUnixPort.h
20.22
KB
-rw-rw-r--
tdbc.h
1.64
KB
-rw-rw-r--
tdbcDecls.h
1.46
KB
-rw-rw-r--
tdbcInt.h
1.24
KB
-rw-rw-r--
term.h
40.77
KB
-rw-rw-r--
term_entry.h
9.02
KB
-rw-rw-r--
termcap.h
3.4
KB
-rw-rw-r--
tic.h
14.5
KB
-rw-rw-r--
tk.h
57.28
KB
-rw-rw-r--
tk3d.h
3.04
KB
-rw-rw-r--
tkArray.h
18
KB
-rw-rw-r--
tkBusy.h
1.58
KB
-rw-rw-r--
tkButton.h
12.2
KB
-rw-rw-r--
tkCanvas.h
11.22
KB
-rw-rw-r--
tkColor.h
2.6
KB
-rw-rw-r--
tkDList.h
16.36
KB
-rw-rw-r--
tkDecls.h
76.04
KB
-rw-rw-r--
tkEntry.h
10.97
KB
-rw-rw-r--
tkFileFilter.h
2.51
KB
-rw-rw-r--
tkFont.h
7.82
KB
-rw-rw-r--
tkImgPhoto.h
8.83
KB
-rw-rw-r--
tkInt.h
47
KB
-rw-rw-r--
tkIntDecls.h
49.68
KB
-rw-rw-r--
tkIntPlatDecls.h
29.12
KB
-rw-rw-r--
tkIntXlibDecls.h
66.76
KB
-rw-rw-r--
tkMacOSX.h
1016
B
-rw-rw-r--
tkMacOSXColor.h
16.57
KB
-rw-rw-r--
tkMacOSXConstants.h
4.9
KB
-rw-rw-r--
tkMacOSXCursors.h
4.21
KB
-rw-rw-r--
tkMacOSXDebug.h
951
B
-rw-rw-r--
tkMacOSXDefault.h
18.11
KB
-rw-rw-r--
tkMacOSXEvent.h
526
B
-rw-rw-r--
tkMacOSXFont.h
798
B
-rw-rw-r--
tkMacOSXInt.h
4.83
KB
-rw-rw-r--
tkMacOSXKeysyms.h
48.88
KB
-rw-rw-r--
tkMacOSXPort.h
4.76
KB
-rw-rw-r--
tkMacOSXPrivate.h
18.39
KB
-rw-rw-r--
tkMacOSXWm.h
10.01
KB
-rw-rw-r--
tkMacOSXXCursors.h
36.92
KB
-rw-rw-r--
tkMenu.h
20.73
KB
-rw-rw-r--
tkMenubutton.h
7.85
KB
-rw-rw-r--
tkPlatDecls.h
6.68
KB
-rw-rw-r--
tkPort.h
632
B
-rw-rw-r--
tkScale.h
8.82
KB
-rw-rw-r--
tkScrollbar.h
6.71
KB
-rw-rw-r--
tkSelect.h
6.61
KB
-rw-rw-r--
tkText.h
45.83
KB
-rw-rw-r--
tkUndo.h
3.59
KB
-rw-rw-r--
tkUnixDefault.h
16.94
KB
-rw-rw-r--
tkUnixInt.h
674
B
-rw-rw-r--
tkUnixPort.h
4.11
KB
-rw-rw-r--
tkUuid.h
92
B
-rw-rw-r--
unctrl.h
3.11
KB
-rw-rw-r--
verto-module.h
6.48
KB
-rw-rw-r--
verto.h
18.98
KB
-rw-rw-r--
zconf.h
16.28
KB
-rw-rw-r--
zdict.h
25.81
KB
-rw-rw-r--
zlib.h
95.04
KB
-rw-rw-r--
zstd.h
167.36
KB
-rw-rw-r--
zstd_errors.h
4.43
KB
-rw-rw-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