From: Jan P. <pa...@pi...> - 2004-05-17 08:59:34
|
Hi, I strongly agree with this your proposal. I also wanted to do it when I was playing with saving last week (I did it just for one function). BTW, your following code introduces memory leak: > - *d = realloc (*d, sizeof (char) * *ds); > + *d = realloc (*d, *ds); > + if (!*d) > + return; If realloc fails, the pointer originally stored in *d is lost. -- Jan > I've just doing some review especially on error handling when doing malloc > and realloc. I think it's not good to declare lot of functions as "void" > and in case of an error just do a "return;" in that case you canot detect > errors and behave respectivly. > > I prefer a to replace at least some void-functions with (signed) int with > a standard return value of 1; if an error happens, they will return > something != 1 (normally < 1). > > This will probably produce at lot more if(function()) constructs, but I > think it's worth. |