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 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>e-memory</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="Evolution API Reference: libedataserver, utility library">
<link rel="up" href="ch01.html" title="Evolution API Reference: libedataserver, utility library">
<link rel="prev" href="libedataserver-EList.html" title="EList">
<link rel="next" href="libedataserver-e-msgport.html" title="e-msgport">
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="ch01.html" title="Evolution API Reference: libedataserver, utility library">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libedataserver-EList.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Evolution API Reference: libedataserver, utility library</th>
<td><a accesskey="n" href="libedataserver-e-msgport.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2557494" class="shortcut">Top</a>
 | 
<a href="#id2579496" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="libedataserver-e-memory"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2557494"></a><span class="refentrytitle">e-memory</span>
</h2>
<p>e-memory — </p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a>;
<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a>* <a href="libedataserver-e-memory.html#e-memchunk-new">e_memchunk_new</a> (int atomcount,
int atomsize);
void* <a href="libedataserver-e-memory.html#e-memchunk-alloc">e_memchunk_alloc</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);
void* <a href="libedataserver-e-memory.html#e-memchunk-alloc0">e_memchunk_alloc0</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);
void <a href="libedataserver-e-memory.html#e-memchunk-free">e_memchunk_free</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m,
void *mem);
void <a href="libedataserver-e-memory.html#e-memchunk-empty">e_memchunk_empty</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);
void <a href="libedataserver-e-memory.html#e-memchunk-clean">e_memchunk_clean</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);
void <a href="libedataserver-e-memory.html#e-memchunk-destroy">e_memchunk_destroy</a> (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);
<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a>;
enum <a href="libedataserver-e-memory.html#EMemPoolFlags">EMemPoolFlags</a>;
<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a>* <a href="libedataserver-e-memory.html#e-mempool-new">e_mempool_new</a> (int blocksize,
int threshold,
<a href="libedataserver-e-memory.html#EMemPoolFlags">EMemPoolFlags</a> flags);
void* <a href="libedataserver-e-memory.html#e-mempool-alloc">e_mempool_alloc</a> (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
int size);
char* <a href="libedataserver-e-memory.html#e-mempool-strdup">e_mempool_strdup</a> (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
const char *str);
void <a href="libedataserver-e-memory.html#e-mempool-flush">e_mempool_flush</a> (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
int freeall);
void <a href="libedataserver-e-memory.html#e-mempool-destroy">e_mempool_destroy</a> (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool);
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>;
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>* <a href="libedataserver-e-memory.html#e-strv-new">e_strv_new</a> (int size);
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>* <a href="libedataserver-e-memory.html#e-strv-set-ref">e_strv_set_ref</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
char *str);
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>* <a href="libedataserver-e-memory.html#e-strv-set-ref-free">e_strv_set_ref_free</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
char *str);
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>* <a href="libedataserver-e-memory.html#e-strv-set">e_strv_set</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
const char *str);
<a href="libedataserver-e-memory.html#EStrv">EStrv</a>* <a href="libedataserver-e-memory.html#e-strv-pack">e_strv_pack</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv);
char* <a href="libedataserver-e-memory.html#e-strv-get">e_strv_get</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index);
void <a href="libedataserver-e-memory.html#e-strv-destroy">e_strv_destroy</a> (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv);
<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>;
<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* <a href="libedataserver-e-memory.html#e-poolv-new">e_poolv_new</a> (unsigned int size);
<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* <a href="libedataserver-e-memory.html#e-poolv-cpy">e_poolv_cpy</a> (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *dest,
const <a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *src);
<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* <a href="libedataserver-e-memory.html#e-poolv-set">e_poolv_set</a> (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv,
int index,
char *str,
int freeit);
const char* <a href="libedataserver-e-memory.html#e-poolv-get">e_poolv_get</a> (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv,
int index);
void <a href="libedataserver-e-memory.html#e-poolv-destroy">e_poolv_destroy</a> (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2579496"></a><h2>Description</h2>
<p>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2579512"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2579523"></a><h3>
<a name="EMemChunk"></a>EMemChunk</h3>
<a class="indexterm" name="id2579535"></a><pre class="programlisting">typedef struct _EMemChunk EMemChunk;</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2579550"></a><h3>
<a name="e-memchunk-new"></a>e_memchunk_new ()</h3>
<a class="indexterm" name="id2579562"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a>* e_memchunk_new (int atomcount,
int atomsize);</pre>
<p>
Create a new memchunk header. Memchunks are an efficient way to allocate
and deallocate identical sized blocks of memory quickly, and space efficiently.
</p>
<p>
e_memchunks are effectively the same as gmemchunks, only faster (much), and
they use less memory overhead for housekeeping.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>atomcount</code></em> :</span></td>
<td> The number of atoms stored in a single malloc'd block of memory.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>atomsize</code></em> :</span></td>
<td> The size of each allocation.
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> The new header.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2579651"></a><h3>
<a name="e-memchunk-alloc"></a>e_memchunk_alloc ()</h3>
<a class="indexterm" name="id2579663"></a><pre class="programlisting">void* e_memchunk_alloc (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2579719"></a><h3>
<a name="e-memchunk-alloc0"></a>e_memchunk_alloc0 ()</h3>
<a class="indexterm" name="id2579731"></a><pre class="programlisting">void* e_memchunk_alloc0 (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2584838"></a><h3>
<a name="e-memchunk-free"></a>e_memchunk_free ()</h3>
<a class="indexterm" name="id2584848"></a><pre class="programlisting">void e_memchunk_free (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m,
void *mem);</pre>
<p>
Free a single atom back to the free pool of atoms in the given
memchunk.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>mem</code></em> :</span></td>
<td> Address of atom to free.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2584912"></a><h3>
<a name="e-memchunk-empty"></a>e_memchunk_empty ()</h3>
<a class="indexterm" name="id2584922"></a><pre class="programlisting">void e_memchunk_empty (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);</pre>
<p>
Clean out the memchunk buffers. Marks all allocated memory as free blocks,
but does not give it back to the system. Can be used if the memchunk
is to be used repeatedly.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2584969"></a><h3>
<a name="e-memchunk-clean"></a>e_memchunk_clean ()</h3>
<a class="indexterm" name="id2584981"></a><pre class="programlisting">void e_memchunk_clean (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);</pre>
<p>
Scan all empty blocks and check for blocks which can be free'd
back to the system.
</p>
<p>
This routine may take a while to run if there are many allocated
memory blocks (if the total number of allocations is many times
greater than atomcount).</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585038"></a><h3>
<a name="e-memchunk-destroy"></a>e_memchunk_destroy ()</h3>
<a class="indexterm" name="id2585050"></a><pre class="programlisting">void e_memchunk_destroy (<a href="libedataserver-e-memory.html#EMemChunk">EMemChunk</a> *m);</pre>
<p>
Free the memchunk header, and all associated memory.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>m</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585100"></a><h3>
<a name="EMemPool"></a>EMemPool</h3>
<a class="indexterm" name="id2585112"></a><pre class="programlisting">typedef struct _EMemPool EMemPool;</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585128"></a><h3>
<a name="EMemPoolFlags"></a>enum EMemPoolFlags</h3>
<a class="indexterm" name="id2585141"></a><pre class="programlisting">typedef enum {
E_MEMPOOL_ALIGN_STRUCT = 0, /* allocate to native structure alignment */
E_MEMPOOL_ALIGN_WORD = 1, /* allocate to words - 16 bit alignment */
E_MEMPOOL_ALIGN_BYTE = 2, /* allocate to bytes - 8 bit alignment */
E_MEMPOOL_ALIGN_MASK = 3, /* which bits determine the alignment information */
} EMemPoolFlags;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585162"></a><h3>
<a name="e-mempool-new"></a>e_mempool_new ()</h3>
<a class="indexterm" name="id2585174"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EMemPool">EMemPool</a>* e_mempool_new (int blocksize,
int threshold,
<a href="libedataserver-e-memory.html#EMemPoolFlags">EMemPoolFlags</a> flags);</pre>
<p>
Create a new mempool header. Mempools can be used to efficiently
allocate data which can then be freed as a whole.
</p>
<p>
Mempools can also be used to efficiently allocate arbitrarily
aligned data (such as strings) without incurring the space overhead
of aligning each allocation (which is not required for strings).
</p>
<p>
However, each allocation cannot be freed individually, only all
or nothing.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>blocksize</code></em> :</span></td>
<td> The base blocksize to use for all system alocations.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>threshold</code></em> :</span></td>
<td> If the allocation exceeds the threshold, then it is
allocated separately and stored in a separate list.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>flags</code></em> :</span></td>
<td> Alignment options: E_MEMPOOL_ALIGN_STRUCT uses native
struct alignment, E_MEMPOOL_ALIGN_WORD aligns to 16 bits (2 bytes),
and E_MEMPOOL_ALIGN_BYTE aligns to the nearest byte. The default
is to align to native structures.
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585296"></a><h3>
<a name="e-mempool-alloc"></a>e_mempool_alloc ()</h3>
<a class="indexterm" name="id2585309"></a><pre class="programlisting">void* e_mempool_alloc (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
int size);</pre>
<p>
Allocate a new data block in the mempool. Size will
be rounded up to the mempool's alignment restrictions
before being used.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>pool</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>size</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585392"></a><h3>
<a name="e-mempool-strdup"></a>e_mempool_strdup ()</h3>
<a class="indexterm" name="id2585405"></a><pre class="programlisting">char* e_mempool_strdup (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
const char *str);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>pool</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>str</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585482"></a><h3>
<a name="e-mempool-flush"></a>e_mempool_flush ()</h3>
<a class="indexterm" name="id2585495"></a><pre class="programlisting">void e_mempool_flush (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool,
int freeall);</pre>
<p>
Flush used memory and mark allocated blocks as free.
</p>
<p>
If <em class="parameter"><code>freeall</code></em> is <a
href="/opt/gnome/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"
><span class="type">TRUE</span></a>, then all allocated blocks are free'd
as well. Otherwise only blocks above the threshold are
actually freed, and the others are simply marked as empty.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>pool</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>freeall</code></em> :</span></td>
<td> Free all system allocated blocks as well.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585586"></a><h3>
<a name="e-mempool-destroy"></a>e_mempool_destroy ()</h3>
<a class="indexterm" name="id2585598"></a><pre class="programlisting">void e_mempool_destroy (<a href="libedataserver-e-memory.html#EMemPool">EMemPool</a> *pool);</pre>
<p>
Free all memory associated with a mempool.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>pool</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585623"></a><h3>
<a name="EStrv"></a>EStrv</h3>
<a class="indexterm" name="id2585634"></a><pre class="programlisting">typedef struct _EStrv EStrv;</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585648"></a><h3>
<a name="e-strv-new"></a>e_strv_new ()</h3>
<a class="indexterm" name="id2585658"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EStrv">EStrv</a>* e_strv_new (int size);</pre>
<p>
Create a new strv (string array) header. strv's can be used to
create and work with arrays of strings that can then be compressed
into a space-efficient static structure. This is useful
where a number of strings are to be stored for lookup, and not
generally edited afterwards.
</p>
<p>
The size limit is currently 254 elements. This will probably not
change as arrays of this size suffer significant performance
penalties when looking up strings with high indices.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>size</code></em> :</span></td>
<td> The number of elements in the strv. Currently this is limited
to 254 elements.
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585724"></a><h3>
<a name="e-strv-set-ref"></a>e_strv_set_ref ()</h3>
<a class="indexterm" name="id2585735"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EStrv">EStrv</a>* e_strv_set_ref (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
char *str);</pre>
<p>
Set a string array element by reference. The string
is not copied until the array is packed.
</p>
<p>
If <em class="parameter"><code>strv</code></em> has been packed, then it is unpacked ready
for more inserts, and should be packed again once finished with.
The memory used by the original <em class="parameter"><code>strv</code></em> is not freed until
the new strv is packed, or freed itself.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>str</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> A new EStrv if the strv has already
been packed, otherwise <em class="parameter"><code>strv</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585851"></a><h3>
<a name="e-strv-set-ref-free"></a>e_strv_set_ref_free ()</h3>
<a class="indexterm" name="id2585862"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EStrv">EStrv</a>* e_strv_set_ref_free (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
char *str);</pre>
<p>
Set a string by reference, similar to set_ref, but also
free the string when finished with it. The string
is not copied until the strv is packed, and not at
all if the index is overwritten.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>str</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> <em class="parameter"><code>strv</code></em> if already unpacked, otherwise an packed
EStrv.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2585962"></a><h3>
<a name="e-strv-set"></a>e_strv_set ()</h3>
<a class="indexterm" name="id2585973"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EStrv">EStrv</a>* e_strv_set (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index,
const char *str);</pre>
<p>
Set a string array reference. The string <em class="parameter"><code>str</code></em> is copied
into the string array at location <em class="parameter"><code>index</code></em>.
</p>
<p>
If <em class="parameter"><code>strv</code></em> has been packed, then it is unpacked ready
for more inserts, and should be packed again once finished with.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>str</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> A new EStrv if the strv has already
been packed, otherwise <em class="parameter"><code>strv</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586093"></a><h3>
<a name="e-strv-pack"></a>e_strv_pack ()</h3>
<a class="indexterm" name="id2586103"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EStrv">EStrv</a>* e_strv_pack (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv);</pre>
<p>
Pack the <em class="parameter"><code>strv</code></em> into a space efficient structure for later lookup.
</p>
<p>
All strings are packed into a single allocated block, separated
by single \0 characters, together with a count byte.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586168"></a><h3>
<a name="e-strv-get"></a>e_strv_get ()</h3>
<a class="indexterm" name="id2586179"></a><pre class="programlisting">char* e_strv_get (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv,
int index);</pre>
<p>
Retrieve a string by index. This function works
identically on both packed and unpacked strv's, although
may be much slower on a packed strv.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586254"></a><h3>
<a name="e-strv-destroy"></a>e_strv_destroy ()</h3>
<a class="indexterm" name="id2586264"></a><pre class="programlisting">void e_strv_destroy (<a href="libedataserver-e-memory.html#EStrv">EStrv</a> *strv);</pre>
<p>
Free a strv and all associated memory. Works on packed
or unpacked strv's.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>strv</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586309"></a><h3>
<a name="EPoolv"></a>EPoolv</h3>
<a class="indexterm" name="id2586320"></a><pre class="programlisting">typedef struct _EPoolv EPoolv;</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586334"></a><h3>
<a name="e-poolv-new"></a>e_poolv_new ()</h3>
<a class="indexterm" name="id2586344"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* e_poolv_new (unsigned int size);</pre>
<p>
create a new poolv (string vector which shares a global string
pool). poolv's can be used to work with arrays of strings which
save memory by eliminating duplicated allocations of the same
string.
</p>
<p>
this is useful when you have a log of read-only strings that do not
go away and are duplicated a lot (such as email headers).
</p>
<p>
we should probably in the future ref count the strings contained in
the hash table, but for now let's not.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>size</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> new pooled string vector
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586412"></a><h3>
<a name="e-poolv-cpy"></a>e_poolv_cpy ()</h3>
<a class="indexterm" name="id2586422"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* e_poolv_cpy (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *dest,
const <a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *src);</pre>
<p>
Copy the contents of a pooled string vector</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>dest</code></em> :</span></td>
<td> destination pooled string vector
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>src</code></em> :</span></td>
<td> source pooled string vector
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> <em class="parameter"><code>dest</code></em>, which may be re-allocated if the strings
are different lengths.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586503"></a><h3>
<a name="e-poolv-set"></a>e_poolv_set ()</h3>
<a class="indexterm" name="id2586513"></a><pre class="programlisting"><a href="libedataserver-e-memory.html#EPoolv">EPoolv</a>* e_poolv_set (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv,
int index,
char *str,
int freeit);</pre>
<p>
Set a string vector reference. If the caller will no longer be
referencing the string, freeit should be TRUE. Otherwise, this
will duplicate the string if it is not found in the pool.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>poolv</code></em> :</span></td>
<td> pooled string vector
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td> index in vector of string
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>str</code></em> :</span></td>
<td> string to set
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>freeit</code></em> :</span></td>
<td> whether the caller is releasing its reference to the
string
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> <em class="parameter"><code>poolv</code></em>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586633"></a><h3>
<a name="e-poolv-get"></a>e_poolv_get ()</h3>
<a class="indexterm" name="id2586644"></a><pre class="programlisting">const char* e_poolv_get (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv,
int index);</pre>
<p>
Retrieve a string by index. This could possibly just be a macro.
</p>
<p>
Since the pool is never freed, this string does not need to be
duplicated, but should not be modified.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>poolv</code></em> :</span></td>
<td> pooled string vector
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>index</code></em> :</span></td>
<td> index in vector of string
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> string at that index.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586723"></a><h3>
<a name="e-poolv-destroy"></a>e_poolv_destroy ()</h3>
<a class="indexterm" name="id2586733"></a><pre class="programlisting">void e_poolv_destroy (<a href="libedataserver-e-memory.html#EPoolv">EPoolv</a> *poolv);</pre>
<p>
Free a pooled string vector. This doesn't free the strings from
the vector, however.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>poolv</code></em> :</span></td>
<td> pooled string vector to free
</td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>
|