From ec2af17674ade115e76c06cf5cde1d1e829460b3 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Wed, 27 Apr 2022 18:34:01 +0300 Subject: [PATCH] CONTRIBUTING.md: update init/finish description --- CONTRIBUTING.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ef9f7c1..65446c18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,7 +167,6 @@ if (condition1 && condition2 && ... Try to break the line in the place which you think is the most appropriate. - ### Line Length Try to keep your lines under 80 columns, but you can go up to 100 if it @@ -190,16 +189,18 @@ Functions that are responsible for constructing objects should take one of the two following forms: * `init`: for functions which accept a pointer to a pre-allocated object (e.g. -a member of a struct) and initialize it. +a member of a struct) and initialize it. Such functions must call `memset()` +to zero out the memory before initializing it to avoid leaving unset fields. * `create`: for functions which allocate the memory for an object, initialize -it, and return a pointer. +it, and return a pointer. Such functions should allocate the memory with +`calloc()` to avoid leaving unset fields. Likewise, functions that are responsible for destructing objects should take one of the two following forms: * `finish`: for functions which accept a pointer to an object and deinitialize -it. Such functions should always be able to accept an already deinitialized -object. +it. If a finished object isn't destroyed but kept for future use, it must be +reinitialized to be used again. * `destroy`: for functions which accept a pointer to an object, deinitialize it, and free the memory. Such functions should always be able to accept a NULL pointer.