El sáb, 19-04-2008 a las 09:31 +0200, [EMAIL PROTECTED] escribió: > Well, a check like: > > pdf_list_create (foo, bar, baz, list) > ... > if (list == NULL) then error PDF_EBADDATA; > ... > > would protect the function for a single case of invalid pointer. But > as I mentioned early in C there is not a way (AFAIK) to determine if a > pointer is valid or invalid. So you are covering the case list == NULL > but not list == 24 (that is likely to be an invalid address) neither > list == 25 or list == 1. >
That is true, but maybe I misunderstood something, are you talking about no testing the NULL pointer in black box testing or neither in the function itself? because at least you can test NULL pointer initialization, It is a good methodology to initialize always pointers to NULL, so if somebody does: pdf_list_t *list=NULL; pdf_list_create(foo, var, baz, list); Would be better to test the NULL case inside the function than no checking at all. I do not know internally the list creation api, and maybe I am saying something wrong, but, Could be possible to always create/reserve the memory inside pdf_list_create function, so we do not mind the incoming pointer list? Regards.
