Skip to content

Commit

Permalink
minor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Jun 28, 2024
1 parent 9c68ea0 commit ff61756
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/rmem.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h1 class="title">src/rmem</h1>
<span class="Comment"># let ptr3 = mp.realloc(ptr1, 150)</span>
<span class="Comment"># Free memory</span>
<span class="Identifier">mp</span><span class="Operator">.</span><span class="Identifier">free</span><span class="Punctuation">(</span><span class="Identifier">ptr2</span><span class="Punctuation">)</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;Free memory after reset: &quot;</span><span class="Punctuation">,</span> <span class="Identifier">mp</span><span class="Operator">.</span><span class="Identifier">getFreeMemory</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;Free memory after free: &quot;</span><span class="Punctuation">,</span> <span class="Identifier">mp</span><span class="Operator">.</span><span class="Identifier">getFreeMemory</span><span class="Punctuation">(</span><span class="Punctuation">)</span>

<span class="Comment"># Example 2: ObjPool</span>
<span class="Keyword">type</span>
Expand Down Expand Up @@ -187,7 +187,7 @@ <h1 class="title">src/rmem</h1>
<span class="Keyword">var</span> <span class="Identifier">bs</span> <span class="Operator">=</span> <span class="Identifier">createBiStack</span><span class="Punctuation">(</span><span class="Identifier">buffer</span><span class="Punctuation">)</span>
<span class="Comment"># Choose between front and back allocations based on the lifetimes and</span>
<span class="Comment"># usage patterns of your data.</span>
<span class="Keyword">let</span> <span class="Identifier">front1</span> <span class="Operator">=</span> <span class="Keyword">cast</span><span class="Punctuation">[</span><span class="Keyword">ptr</span> <span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">bs</span><span class="Operator">.</span><span class="Identifier">allocFront</span><span class="Punctuation">(</span><span class="Identifier">sizeof</span><span class="Punctuation">(</span><span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># Memory is not cleared!</span>
<span class="Keyword">let</span> <span class="Identifier">front1</span> <span class="Operator">=</span> <span class="Keyword">cast</span><span class="Punctuation">[</span><span class="Keyword">ptr</span> <span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">bs</span><span class="Operator">.</span><span class="Identifier">allocFront</span><span class="Punctuation">(</span><span class="Identifier">sizeof</span><span class="Punctuation">(</span><span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
<span class="Keyword">let</span> <span class="Identifier">back1</span> <span class="Operator">=</span> <span class="Keyword">cast</span><span class="Punctuation">[</span><span class="Keyword">ptr</span> <span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">bs</span><span class="Operator">.</span><span class="Identifier">allocBack</span><span class="Punctuation">(</span><span class="Identifier">sizeof</span><span class="Punctuation">(</span><span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
<span class="Identifier">front1</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">10</span>
<span class="Identifier">back1</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">20</span>
Expand Down Expand Up @@ -470,7 +470,7 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br>
<small style="color: var(--hint);">Made with Nim. Generated: 2024-06-28 22:22:56 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2024-06-28 22:27:41 UTC</small>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/rmem.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ****************************************************************************************
#
# rmem v1.0 - memory pool and objects pool
# rmem v1.0 - memory pool and objects pool - nim version
#
# DESCRIPTION:
# A quick, efficient, and minimal free list and arena-based allocator
Expand Down Expand Up @@ -61,7 +61,7 @@ runnableExamples:
var bs = createBiStack(buffer)
# Choose between front and back allocations based on the lifetimes and
# usage patterns of your data.
let front1 = cast[ptr int](bs.allocFront(sizeof(int))) # Memory is not cleared!
let front1 = cast[ptr int](bs.allocFront(sizeof(int)))
let back1 = cast[ptr int](bs.allocBack(sizeof(int)))
front1[] = 10
back1[] = 20
Expand Down

0 comments on commit ff61756

Please sign in to comment.