Note that there are some explanatory texts on larger screens.

plurals
  1. POsys/queue.h: Use of LIST_REMOVE
    primarykey
    data
    text
    <p>I'm trying to use the <code>sys/queue.h</code> file from OpenBSD to manipulate a linked list.</p> <p>I am writing a cache engine for a small microcontroller. Pages are stored in the cache when used, and removed when the memory is needed for other things like malloc.</p> <p>This task needs to find the minimum hit count cache page (the one with the least number of hits is the least likely to be used) and free it. However, I'm hitting upon a fairly simple error.</p> <p>This is my function so far:</p> <pre><code>void _fmem_cache_malloc_purge(int requested_size) { int n = ((requested_size / FMEM_SECTOR_SIZE) + 1) * FMEM_SECTOR_SIZE; struct s_fmem_cache_entry *entry, *lowentry; long int lowhits; fmem_acquire(); for(; n &gt; 0; n--) { // Traverse the cache table. Find an entry with a minimum number of hits. lowhits = -1; LIST_FOREACH(entry, &amp;fmem_cache, entry_ptr) { if(lowhits == -1 || lowhits &gt; entry-&gt;hits) { lowentry = entry; lowhits = entry-&gt;hits; } } // Free the minimum entry. assert(lowhits &gt; 0); LIST_REMOVE(lowentry, entry_ptr); &lt;-- error occurs here (line 170) mmgr_free(lowentry-&gt;data); mmgr_free(lowentry); fmem_cache_size--; } fmem_release(); } </code></pre> <p>Definitions (near the top of the same file):</p> <pre><code>struct s_fmem_cache_entry { fAddr addr; char data[FMEM_SECTOR_SIZE]; long int hits, ctime; LIST_ENTRY(fmem_cache_entry) entry_ptr; }; LIST_HEAD(s_fmem_cache_head, s_fmem_cache_entry) fmem_cache; </code></pre> <p>The error I'm getting is:</p> <pre><code>flashmem.c: In function '_fmem_cache_malloc_purge': flashmem.c:160: warning: assignment from incompatible pointer type flashmem.c:170: error: dereferencing pointer to incomplete type </code></pre> <p>I feel like it's a simple error, but C is new to me. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload