|
From: Lucas B. <bra...@re...> - 2004-09-22 14:24:09
|
Hi!
I think I'm messing out something, but can't figure out
some invalid writes valgrind pointing me out.
I'm implementing a linked list for a server I'm writing that
will store user configuration from a file. So I did:
struct _LinkedList
{
char *key;
char *data;
struct _LinkedList *next;
struct _LinkedList *head;
};
typedef struct _LinkedList LinkedList;
int main(void)
{
LinkedList *usersettings;
usersettings = newLinkedList();
}
LinkedList *newLinkedList(void)
{
LinkedList *s;
/* memory allocation for LinkedList structure */
s = (LinkedList *)malloc (sizeof (LinkedList *));
if (!s)
return s;
/* storing list's head */
s->head = s; /* invalid write ???? */
s->next = NULL; /* invalid write ???? */
s->key = NULL; /* Here valgrind says it's ok (no invalid write) */
s->data = NULL; /* invalid write ???? */
return s;
}
Any tip or help?
thanks a lot in advance:
--
[]'s
Lucas Brasilino
bra...@re...
http://www.recife.pe.gov.br
Emprel - Empresa Municipal de Informatica (pt_BR)
Municipal Computing Enterprise (en_US)
Recife - Pernambuco - Brasil
Fone: +55-81-34167078
|