ONEEYEMAN wrote:Hi,
This is a very weird implementation of a linked list.
Why do you even need it as you use just one value there? Can't you just use _str_copy?
Or you just didn't post the parsing code?
Anyway LL is a double pointer implementation - one is for LL itself and one is for node.
You need to rewrite the code to use proper LL implementation.
Thank you.
I have a full library (my own one) for linked lists, the implementation is fine - it hasn't failed; there a lot more functions to work with it. The linked list is needed as the size is dynamic and using an array isn't going to allow me to do several things.
the lists header
Code: Select all
typedef struct node_ node_t;
struct node_
{
const char * value;
struct node_ * next;
};
typedef void (*list_event_cb_t)(node_t * head);
static void list_cb_register(list_event_cb_t * register_cb_func, node_t * head)
{
(*register_cb_func)(head);
}
void list_traverse(node_t * head);
void list_display(node_t * head);
int list_count(node_t * head);
node_t * list_create(const char * value, node_t * head);
node_t * list_append(node_t * head, const char * value);
void list_remove_start(node_t * head);
void list_remove_end(node_t * head);
node_t * list_dispose(node_t * head);
There are 2 checks, I don't want to post the source as it's probably against rules here - I am not doing anything illegal, it's all for software to run on work machines.
When a user types every letter is collected (monitored), when you hit delete the program navigates the list and removes what was deleted. When using the arrow keys pressed etc. You get the idea? It's like a mirror of whatever the user is typing into the terminal and it's all checked at runtime and while it's being typed. So far there is no performance hit and it seems to run fine in the background.
When you hit space or enter the program checks against values that *the boss* can enter into a website portal (admin area); these are automatically updated into the daemon software but at the moment having a little issue with the strncpy() *what I've posted*.
The memory problem (I definitely don't want dangling pointers) is the only thing so far that is bothering me.