|
|
@@ -0,0 +1,59 @@
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
+
|
|
|
+//type dfinitions
|
|
|
+typedef struct lin_list
|
|
|
+ {
|
|
|
+ char *value;
|
|
|
+ struct lin_list *next;
|
|
|
+ }LinListCell, *LinList_p;
|
|
|
+
|
|
|
+//function derfinitions
|
|
|
+
|
|
|
+LinList_p LinListAllocCell(char* value);
|
|
|
+void LinListFreeCell(LinList_p junk);
|
|
|
+void LinListFree(LinList_p *junk);
|
|
|
+LinList_p LinListInsertFirst(LinList_p anchor,LinList_p newCell);
|
|
|
+
|
|
|
+int main(void)
|
|
|
+{
|
|
|
+ printf("blaa\n");
|
|
|
+ LinList_p anchor = LinListAllocCell("xx");
|
|
|
+ anchor->next = LinListAllocCell("xc");
|
|
|
+ printf("anchor=%p\n",anchor);
|
|
|
+ printf("%p %p \n", anchor->value,anchor->next->value);
|
|
|
+}
|
|
|
+
|
|
|
+LinList_p LinListInsertFirst(LinList_p anchor,LinList_p newCell)
|
|
|
+{
|
|
|
+ LinListCell *buff = anchor;
|
|
|
+ anchor = LinListAllocCell("");
|
|
|
+ anchor->next = buff;
|
|
|
+}
|
|
|
+
|
|
|
+LinList_p LinListAllocCell(char* value)
|
|
|
+
|
|
|
+{
|
|
|
+ LinList_p newcell = malloc(sizeof(LinListCell));
|
|
|
+ newcell->next = NULL;
|
|
|
+ newcell->value = strdup(value);
|
|
|
+ return newcell;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void LinListFreeCell(LinList_p junk)
|
|
|
+{
|
|
|
+ free(junk);
|
|
|
+}
|
|
|
+
|
|
|
+void LinListFree(LinList_p *junk)
|
|
|
+{
|
|
|
+ LinListCell *next = junk;
|
|
|
+ LinListCell *buff;
|
|
|
+ *junk = NULL;
|
|
|
+ while(next != NULL)
|
|
|
+ {
|
|
|
+ buff = next->next;
|
|
|
+ free(next);
|
|
|
+ }
|
|
|
+}
|