💾 Archived View for gmi.noulin.net › gitRepositories › linkedList › file › main.c.gmi captured on 2024-07-09 at 02:21:36. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

linkedList

Log

Files

Refs

README

LICENSE

main.c (1612B)

     1 #! /usr/bin/env sheepy
     2 /* or direct path to sheepy: #! /usr/local/bin/sheepy */
     3 
     4 /* Libsheepy documentation: http://spartatek.se/libsheepy/ */
     5 #include "libsheepyObject.h"
     6 #include "linkedList.h"
     7 #include "linkedListe.h"
     8 int argc; char **argv;
     9 
    10 /* enable/disable logging */
    11 /* #undef pLog */
    12 /* #define pLog(...) */
    13 
    14 int main(int ARGC, char** ARGV) {
    15 
    16   argc = ARGC; argv = ARGV;
    17 
    18   initLibsheepy(ARGV[0]);
    19   setLogMode(LOG_FUNC);
    20 
    21 
    22   // llist linked list
    23 
    24   // define list:
    25   llistT(llt, u32);
    26 
    27   // declare list:
    28   llt ll;
    29 
    30   // initialize:
    31   llistInit(&ll);
    32 
    33   // push element:
    34   llistPush(&ll);
    35   llistLast(&ll) = 1;
    36 
    37   logVarG(llistCount(&ll));
    38 
    39   // Pop/dellast element:
    40   llistPop(&ll);
    41 
    42   // Free
    43   llistFree(&ll);
    44 
    45 
    46 
    47 
    48 
    49   // lliste linked list with external storage
    50 
    51   // define list:
    52   llisteT(llet, u32);
    53 
    54   // declare list:
    55   llet lle;
    56 
    57   // initialize node storage
    58   // local
    59   llisteNodesT(&lle) nodeStore;
    60   llisteFreeNodesT(&lle) freeNodeStore;
    61   llisteStoreInit(&nodeStore, &freeNodeStore);
    62 
    63   /* // or on heap */
    64   /* llisteNodesPtrT(&lle) nodeStore; */
    65   /* llisteFreeNodesPtrT(&lle) freeNodeStore; */
    66   /* nodeStore     = malloc(sizeof(llisteNodesT(&lle))); */
    67   /* freeNodeStore = malloc(sizeof(llisteFreeNodesT(&lle))); */
    68 
    69   // initialize:
    70   llisteInit(&lle, &nodeStore, &freeNodeStore);
    71 
    72   // push element:
    73   llistePush(&lle);
    74   llisteLast(&lle) = 1;
    75 
    76   // Pop/delleast element:
    77   llistePop(&lle);
    78 
    79   // Free
    80   llisteFree(&lle);
    81 
    82   // free node storage, after this all lists using this storage are invalid
    83   llisteStoreFree(&nodeStore, &freeNodeStore);
    84 
    85 }
    86 // vim: set expandtab ts=2 sw=2: