aboutsummaryrefslogtreecommitdiff
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-04-27 18:34:01 +0300
committerKirill Primak <vyivel@eclair.cafe>2022-04-28 08:30:26 +0000
commitec2af17674ade115e76c06cf5cde1d1e829460b3 (patch)
tree38316ae15a7169fef53fd0473dcb897d791300c4 /CONTRIBUTING.md
parenta1e1e9aba8d1ccbd9582be659c5d3d2e587214ff (diff)
CONTRIBUTING.md: update init/finish description
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md11
1 files 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.