-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.html
827 lines (690 loc) · 23.4 KB
/
docs.html
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
<!DOCTYPE html>
<html lang="en">
<title>phbase documentation</title>
<head>
<style>
:root {
--background-color: #fdf6e3;
--link-inactive-color: #57697b;
--link-active-color: #2FACAD;
--code-color: #181818;
--block-clickable-color: #defafa;
}
html {
background-color: var(--background-color);
}
section, section:target ~ section:last-of-type {
display: none;
}
section:target, section:last-of-type {
display: inherit;
}
div.navigation {
font-family: monospace;
letter-spacing: 5px;
font-weight: bold;
max-width: 800px;
margin: 0 auto;
padding: 10px;
text-decoration: none;
}
div.text {
padding: 20px 0;
}
a:link, a:visited {
text-decoration: none;
color: var(--link-inactive-color);
}
a:hover {
color: var(--link-active-color);
}
code {
color: var(--code-color);
}
#content {
max-width: 800px;
margin: 0 auto;
padding: 10px;
font-size: 18px;
line-height: 1.5;
text-align: justify;
}
#header-title {
font-family: monospace;
font-size: 28px;
font-weight: bold;
text-align: center;
margin-top: 80px;
margin-bottom: 100px;
letter-spacing: 20px;
}
#footer {
font-size: 12px;
text-align: center;
margin-top: 80px;
}
h3.libentity {
font-family: monospace;
white-space: pre;
}
table.links {
padding-top: 20px;
width: 100%
}
.links tr:hover {
background-color: var(--block-clickable-color);
}
table.params {
max-width: 600px;
font-size: 0.9em;
}
.params td {
padding: 6px 7px;
}
.code {
font-family: monospace;
white-space: pre;
color: var(--code-color);
}
</style>
</head>
<body>
<header>
<div id="header-title">
<a class="site-title" href="#">phbase</a>
</div>
<div class="navigation">
<a href="#about">about</a>
<a href="#reference">reference</a>
</div>
</header>
<div id="content">
<section id="reference">
<div class="links">
<table class="links">
<tr onclick="window.location='#core';">
<td><a class="navigation" href="#core">core</a></td>
<td>core utilities</td>
</tr>
<tr onclick="window.location='#status';">
<td><a class="navigation" href="#status">status</a></td>
<td>status codes for phbase operations.</td>
</tr>
<tr onclick="window.location='#utf8';">
<td><a class="navigation" href="#utf8">utf8</a></td>
<td>utf-8 decoding function</td>
</tr>
<tr onclick="window.location='#extrusion';">
<td><a class="navigation" href="#extrusion">extrusion</a></td>
<td>recovering structure addresses from members.</td>
</tr>
<tr onclick="window.location='#arena';">
<td><a class="navigation" href="#arena">arena</a></td>
<td>lightweight arena allocator</td>
</tr>
<tr onclick="window.location='#dynarray';">
<td><a class="navigation" href="#dynarray">dynarray</a></td>
<td>dynamic array for standard alignment types.</td>
</tr>
<tr onclick="window.location='#ptrdex';">
<td><a class="navigation" href="#ptrdex">ptrdex</a></td>
<td>hash-table with pointer type keys.</td>
</tr>
</table>
</div>
</section>
<section id="core">
<h2>core</h2>
<p><code>phbase/core.h</code> provides small tools which are generally useful.</p>
<div class="reference">
<h3 class="libentity">PHBASE_STATIC_ARRAY_LENGTH(a)</h3>
<p>For statically defined arrays, determine the array length at compile time.</p>
</div>
<div class="reference">
<h3 class="libentity">PHBASE_STATIC_STRLEN(s)</h3>
<p>For statically defined strings, determine the string length at compile time. Doesn't count the null terminating byte.</p>
</div>
<div class="reference">
<h3 class="libentity">PHBASE_UNUSED_PARAMETER(p)</h3>
<p>Used inside procedure bodies to declare a parameter unused.</p>
</div>
</section>
<section id="status">
<h2>status</h2>
<p><code>phbase/status.h</code> provides status codes used in <code>phbase</code>.</p>
<div class="reference">
<h3 class="libentity">enum phbase_status</h3>
<p>Enum of status codes returned by phbase operations. The descriptions below provide a general idea of what the status codes might mean for a given operation. Refer to the documentation for the operation in question for detailed information on what failures mean.</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>The operation completed successfully. Always takes the value <code>0</code>.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_DOES_NOT_EXIST</td>
<td>A requested entity does not exist.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_NO_MEMORY</td>
<td>The operation failed to complete because there was insufficient memory.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_INVALID_PARAMETER</td>
<td>A provided parameter was not valid for the operation.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_FULL</td>
<td>The operation failed because an entity was full.</td>
</tr>
</table>
</div>
</section>
<section id="utf8">
<h2>utf8</h2>
<p><code>phbase/utf8.h</code> provides simple facilities for decoding utf-8 encoded character streams.</p>
<div class="reference">
<h3 class="libentity">phbase_codepoint</h3>
<p>Integer type for a unicode codepoint.</p>
</div>
<div class="reference">
<h3 class="libentity">size_t<br>phbase_utf8_decode_character(phbase_codepoint* out,
size_t length, const uint8_t* bytes)</h3>
<p>UTF-8 decode a single unicode codepoint from an array of bytes. Returns the number of bytes decoded from the array. If the passed length is non-zero and <code>phbase_utf8_decode_character</code> returns zero, then the byte array does not start with a valid utf-8 byte sequence.</p>
<table class="params">
<tr>
<td class="code">out</td>
<td>A place to write the value of a successfully decoded codepoint.</td>
</tr>
<tr>
<td class="code">length</td>
<td>The length of the bytestring to decode from.</td>
</tr>
<tr>
<td class="code">bytes</td>
<td>An array of bytes to decode or length at least <code>length</code></td>
</tr>
</table>
</div>
</section>
<section id="extrusion">
<h2>extrusion</h2>
<p><code>phbase/extrusion.h</code> provides a macro for recovering the base address of a structure from the address of a member.</p>
<div class="reference">
<h3 class="libentity">ty*<br>PHBASE_EXTRUDE(v, ty, member)</h3>
<p>Takes a pointer to a member of a structure, and recovers a pointer to the structure.</p>
<table class="params">
<tr>
<td class="code">v</td>
<td>Pointer to a member of structure.</td>
</tr>
<tr>
<td class="code">ty</td>
<td>The name of the structure.</td>
</tr>
<tr>
<td class="code">member</td>
<td>The member of <code>ty</code> pointed to by <code>v</code></td>
</tr>
</table>
<p>This is often used with intrusive data structures to gain access to the data that the intrusive data structure manages.</p>
</div>
</section>
<section id="arena">
<h2>arena</h2>
<p><code>phbase/arena.h</code> provides a bump allocator. All elements are freed at once via the reset procedure, or by freeing the underlying memory block.</p>
<div class="reference">
<h3 class="libentity">struct phbase_arena</h3>
<p>Structure for the control block of an arena allocator. Should be treated as an opaque structure and not manipulated directly.</p>
</div>
<div class="reference">
<h3 class="libentity">void<br>phbase_arena_init(struct phbase_arena* a, size_t size, void* memory)</h3>
<p>Initialize an arena with a preallocate block of memory with a given size.</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>The arena to initialize.</td>
</tr>
<tr>
<td class="code">size</td>
<td>The size of the memory in bytes that the arena should manage.</td>
</tr>
<tr>
<td class="code">memory</td>
<td>A block of memory to manage - doesn't take ownership so the user is responsible for its lifetime.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">void<br>phbase_arena_reset(struct phbase_arena* a)</h3>
<p>Throw away all previous allocations (won't zero the memory block).</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>A pointer to the arena to reset.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">void*<br>phbase_arena_allocate(struct phbase_arena* a, size_t align, size_t size)</h3>
<p>Aligned allocation in the arena. Returns <code>NULL</code> if the arena is exhausted, otherwise returns a pointer to the allocated memory.<p>
<table class="params">
<tr>
<td class="code">a</td>
<td>The arena to allocate from.</td>
</tr>
<tr>
<td class="code">align</td>
<td>The alignment of the allocation.</td>
</tr>
<tr>
<td class="code">size</td>
<td>The size of the allocation.</td>
</tr>
</table>
</div>
</section>
<section id="dynarray">
<h2>dynarray</h2>
<p><code>phbase/dynarray.h</code> provides a dynamic array for types with alignment less than <code>alignof(max_align_t)</code>.</p>
<p>The intention here is to imbue normal pointers with a set of operations for dynamically sized arrays. A marker <code>PHBASE_DYNARRAY</code> is provided, which expands to nothing, in order to help declare intent.</p>
<p>Currently dynamic arrays use the standard C library allocators for allocating memory. Support for custom allocators will be added.</p>
<p>Operations on this data structure are not guaranteed to be threadsafe.</p>
<p>Most operations here are implemented as macros wrapping generic procedures.</p>
<pre>
/* Example program showing simple usage. */
#include <phbase/dynarray.h>
#include <stddef.h> /* EXIT_SUCCESS, EXIT_FAILURE */
int
main(int argc, char* argv[])
{
PHBASE_DYNARRAY int* a = { 0 };
if (phbase_dynarray_init_with_capacity(&a, 1) != PHBASE_STATUS_OK)
{
return EXIT_FAILURE;
}
int ret = EXIT_SUCCESS;
if (phbase_dynarray_push(&a, 0) || phbase_dynarray_push(&a, 1))
{
ret = EXIT_FAILURE;
goto error;
}
if (phbase_dynarray_length(&a) != 2)
{
ret = EXIT_FAILURE;
goto error;
}
if (a[0] != 0 || a[1] != 1)
{
ret = EXIT_FAILURE;
goto error;
}
error:
phbase_dynarray_clear(&a);
return ret;
}
</pre>
<div class="reference">
<h3 class="libentity">PHBASE_DYNARRAY</h3>
<p>A marker for dynamic array types. Intended just to declare intent, since this macro expands to nothing.</p>
</div>
<div class="reference">
<h3 class="libentity">PHBASE_DYNARRAY_TYPE_IS_SUPPORTED(ty)</h3>
<p><i>C11 and above</i></p>
<p>Macro to determine whether the type <code>ty</code> can be stored in a dynamic array.</p>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_dynarray_init_with_capacity(ty** a, size_t capacity)</h3>
<p>Initializes the dynamic array <code>a</code> to hold up to <code>capacity</code> elements of type <code>ty</code> without reallocation.<p>
<p>On error, <code>a</code> is left untouched.<p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array to initialize.</td>
</tr>
<tr>
<td class="code">capacity</td>
<td>The initial capacity of the array.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>The dynamic array was successfully initialized.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_NO_MEMORY</td>
<td>Could not initialize a dynamic array of the given capacity because there was insufficient memory.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">void<br>phbase_dynarray_clear(ty** a)</h3>
<p>Clears the memory allocated to the dynamic array <code>a</code>, and zeros <code>*a</code>.
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array to clear.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">size_t<br>phbase_dynarray_length(ty** a)</h3>
<p>Query the current length of a dynamic array.</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">size_t<br>phbase_dynarray_capacity(ty** a)</h3>
<p>Query the current capacity (number of values which can be stored without reallocation) of a dynamic array.</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_dynarray_set_length(ty** a, size_t length)</h3>
<p>
Explicitly set length of the dynamic array.
Will succeed only if <code>length</code> is less than the capacity of the array.
</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array.</td>
</tr>
<tr>
<td class="code">length</td>
<td>The requested length.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>Successfully set the length of the array.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_INVALID_PARAMETER</td>
<td><code>a</code> has capacity less than the specified length.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_dynarray_push(ty** a, ty v)</h3>
<p>Push the value <code>v</code> onto the end of the array. The only way this can fail is if there is no capacity in the current allocation, and memory reallocation fails.</p>
<p>If there is sufficient capacity in the dynamic array, <code>*a</code> is left unchanged. Reallocation may cause <code>a</code> to change.</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array.</td>
</tr>
<tr>
<td class="code">v</td>
<td>The value to push onto the end of the array.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>Successfully pushed the value <code>v</code> onto the end of <code>a</code>.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_NO_MEMORY</td>
<td><code>a</code> is at capacity, and pushing was unable to allocate more memory.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_dynarray_pop(ty** a, ty* out)</h3>
<p>Pop an element off the end of the array, writing it to the location pointed to by out. On error, <code>*out</code> is unmodified.</p>
<table class="params">
<tr>
<td class="code">a</td>
<td>Pointer to the dynamic array.</td>
</tr>
<tr>
<td class="code">out</td>
<td>Pointer to the location to write the popped element.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>Successfully popped an element off the end of <code>a</code>, and wrote it to <code>out</code>.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_DOES_NOT_EXIST</td>
<td><code>a</code> is empty, so no element could be popped. <code>out</code> remains unchanged.</td>
</tr>
</table>
</div>
</section>
<section id="ptrdex">
<h2>ptrdex</h2>
<p><code>phbase/ptrdex.h</code> provides a hash-table for pointer typed keys. It provides a basic control structure which can be unioned with an anonymous struct. The names used to construct these structures and unions are fixed to allow a set of macros to be used to manipulate these tables in a fairly generic way.</p>
<p>The following example illustrates how to setup the table properly, and then how to use the set of macros to work with it.</p>
<pre>
int
test_string_keys()
{
int rc = 0;
static const char* keys[] = {
"foo", "bar", "baz"
};
/* The table is setup by including an internal member, with the table
* structure, unioned with an anonymous struct consisting of an array
* key containing keys, and an array value, containing values.
*
* This table maps const char* keys to uint32_t values. */
union {
struct phbase_ptrdex__internal internal;
struct {
const char** key;
uint32_t* value;
};
} ht = { 0 };
if (phbase_ptrdex_init_with_capacity(&ht, 32) != PHBASE_STATUS_OK)
{
rc = 1;
goto error;
}
/* First insert some key value pairs. */
for (uint32_t ix = 0; ix < PHBASE_STATIC_ARRAY_LENGTH(keys); ++ix)
{
struct phbase_ptrdex_locator l = { 0 };
if (phbase_ptrdex_obtain_slot(&ht, keys[ix], &l) != PHBASE_STATUS_OK)
{
rc = 1;
goto error;
}
phbase_ptrdex_insert(&ht, l, keys[ix], ix);
}
/* Now look for a value by key. */
size_t slot = 0;
if (phbase_ptrdex_find(&ht, keys[1], &slot) != PHBASE_STATUS_OK)
{
rc = 1;
goto error;
}
printf("The value at '%s' is %u\n", ht.key[slot], ht.value[slot]);
error:
if (phbase_ptrdex_is_initialized(&ht))
{
phbase_ptrdex_clear(&ht);
}
return rc;
}
</pre>
<div class="reference">
<h3 class="libentity">struct phase_ptrdex__internal</h3>
<p>Structure for providing hash-table functionality. Should be treated as opaque, and should be unioned with an anonymous struct containing a pointer to a key, and a pointer to a value.</p>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_ptrdex_init_with_capacity(ty* table, size_t capacity)</h3>
<p>Initializes a table with a given capacity.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to initialize.</td>
</tr>
<tr>
<td class="code">capacity</td>
<td>The capacity to initialize with.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>The table was successfully initialized.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_NO_MEMORY</td>
<td>The table could not be initialized because it would use too much memory.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_INVALID_PARAMETER</td>
<td><code>capacity</code> was not valid. Currently capacity is limited to 2<sup>32</sup> - 1. This limitation is planned to be lifted.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">void<br>phbase_ptrdex_clear(ty* table)</h3>
<p>Clears an initialized table.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to initialize.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_ptrdex_is_initialized(ty* table)</h3>
<p>Determines if a table is initialized.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to test for initialization.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">true</td>
<td>The table is successfully initialized.</td>
</tr>
<tr>
<td class="code">false</td>
<td>The table is not initialized.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_ptrdex_find(ty* table, key_ty key, size_t* out)</h3>
<p>Finds the slot where a key is located.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to lookup key in.</td>
</tr>
<tr>
<td class="code">key</td>
<td>The key to lookup.</td>
</tr>
<tr>
<td class="code">out</td>
<td>A pointer to a location to write the slot in which key is found.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>The value was found, and out now contains the slot in which to find key.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_DOES_NOT_EXIST</td>
<td><code>key</code> was not found in the table.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">struct phbase_ptrdex_locator</h3>
<p>Structure for storing location information when obtaining a slot for inserting a new key-value pair. Should be treated as opaque.</p>
</div>
<div class="reference">
<h3 class="libentity">int<br>phbase_ptrdex_obtain_slot(ty* table, key_ty key, struct phbase_ptrdex_locator* out)</h3>
<p>Obtains a slot to insert a key-value pair.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to lookup key in.</td>
</tr>
<tr>
<td class="code">key</td>
<td>The key to lookup.</td>
</tr>
<tr>
<td class="code">out</td>
<td>A pointer to a <code>struct phbase_ptrdex_locator</code> which can be used to insert a key-value pair.</td>
</tr>
</table>
<p>Return value</p>
<table class="params">
<tr>
<td class="code">PHBASE_STATUS_OK</td>
<td>A slot was found, and <code>out</code> can now be used to insert the key-value pair.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_FULL</td>
<td>The table has reached its maximum size, but would need growing to support the new key.</td>
</tr>
<tr>
<td class="code">PHBASE_STATUS_NO_MEMORY</td>
<td>Could not obtain a slot, because obtaining a slot required the table to grow, and there is insufficient memory.</td>
</tr>
</table>
</div>
<div class="reference">
<h3 class="libentity">void<br>phbase_ptrdex_insert(ty* table, struct phbase_ptrdex_locator locator, key_ty key, value_ty value)</h3>
<p>Insert a key-value pair into the table using a locator.</p>
<table class="params">
<tr>
<td class="code">table</td>
<td>The table to insert into.</td>
</tr>
<tr>
<td class="code">locator</td>
<td>A locator used to insert a key-value pair.</td>
</tr>
<tr>
<td class="code">key</td>
<td>The key to insert with.</td>
</tr>
<tr>
<td class="code">value</td>
<td>The value to insert at key</td>
</tr>
</table>
</div>
</section>
<section id = "about">
<div class="text">
<code>phbase</code> is a library of <code>C</code> utlities which are useful for everyday programming. It is licensed under the MIT license.
</div>
</section>
</div>
<div id="footer">
<p><i>phbase © Richard Lupton 2022</i></p>
</div>
</body>
</html>