Re: Why check NPP instance != NULL?
Benjamin Smedberg <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.plugins |
|---|---|
| Message-ID | <[email protected]> |
On 4/15/11 5:32 PM, Oleksandr Gavenko wrote: > > They use such pattern: > > if (instance==NULL) > return NPERR_INVALID_INSTANCE_ERROR; > > for functions that pass 'NPP instance' arg (like NPP_New, NPP_Destroy, > NPP_GetValue). > > Why this need? We are practicing defensive programming. The null check is cheap, and since we really don't know whether plugin code might have bugs, we just do it for sanity's sake. --BDS