]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/doc/mempool.txt
XTypes: Added support to configuration and option parser.
[libucw.git] / ucw / doc / mempool.txt
index d3fc4c0612a7038b5641dbdf524247e17b38cb13..5aa33ddd2e981f4c8d219ceb1841ecfe828c2639 100644 (file)
@@ -49,7 +49,7 @@ not need to walk trough it and free each node, you just
 
   struct trie *trie_new(void) {
     struct mempool *pool = mn_new(4096);
-    struct trie *result = mp_alloc_zero(pool, sizeof *result);
+    struct trie *result = mp_alloc_zero(pool, sizeof(*result));
     result->pool = pool;
     return result;
   }
@@ -57,7 +57,7 @@ not need to walk trough it and free each node, you just
   void trie_insert_internal(struct trie_node *where, struct mempool *pool, const char *string) {
     if(*string) {
       if(!where->subs[*string])
-        where->subs[*string] = mp_alloc_zero(pool, sizeof *where->subs[*string]);
+        where->subs[*string] = mp_alloc_zero(pool, sizeof(*where->subs[*string]));
       trie_insert_internal(where->subs[*string], pool, string + 1);
     } else {
       where->present = 1;
@@ -89,7 +89,7 @@ mempool state.
   void load_file(struct mempool *pool, const char *file) {
     struct mempool_state state;
     mp_save(pool, &state);              // Store the current state
-    struct file_data *data = mp_alloc_zero(pool, sizeof *data);
+    struct file_data *data = mp_alloc_zero(pool, sizeof(*data));
     if(!(
         file_open(file, data, pool) &&  // Load the file
         header_load(data, pool) &&
@@ -112,7 +112,7 @@ This example uses libucw's own IO system, <<fastbuf:,fastbufs>>.
 
   void *stdin_data(struct mempool *pool) {
     struct fastbuf *fb = bopen_fd(0, NULL);     // Read from stdin
-    uns amount;
+    size_t amount;
     char *ptr = mp_start(pool, 1024);
     while(amount = bread(fb, ptr, 1024)) {      // Read a block
       ptr += amount;                            // Move after it