Skip to content

Instantly share code, notes, and snippets.

@rohanrhu
Last active December 24, 2020 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohanrhu/f650d0080f9069eff4d2cacb32417590 to your computer and use it in GitHub Desktop.
Save rohanrhu/f650d0080f9069eff4d2cacb32417590 to your computer and use it in GitHub Desktop.
GDBFrontend Linked-List Visualizer Example Program
/*
* Example for GDBFrontend Linked-List Visualizer
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct llist llist_t;
struct llist {
int id;
llist_t* prev;
llist_t* next;
};
int llist_id_i = 0;
llist_t* llist_create() {
llist_t* llist = malloc(sizeof(llist));
llist->id = ++llist_id_i;
llist->prev = NULL;
llist->next = NULL;
return llist;
}
void llist_add(llist_t* item, llist_t* to) {
item->prev = to;
to->next = item;
}
int main() {
printf("Example for GDBFrontend Linked-List Visualizer\n");
llist_t* llist = llist_create();
llist_t* to = llist;
llist_t* current;
for (int i=0; i < 10; i++) {
current = llist_create();
llist_add(current, to);
to = current;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment