Changeset 1286893


Ignore:
Timestamp:
Mar 7, 2010, 11:50:32 PM (10 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2ee9e8d
Parents:
f8074e9
git-author:
Anders Kaseorg <andersk@mit.edu> (03/07/10 23:29:10)
git-committer:
Anders Kaseorg <andersk@mit.edu> (03/07/10 23:50:32)
Message:
Document the init/cleanup vs. new/delete naming conventions.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Nelson Elhage <nelhage@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/code.txt

    rd7cc50b r1286893  
    183183-------------------------------
    184184
    185         There are no hard rules for memory allocation.  In general I
    186         have the caller allocate memory for objects themselves and any
    187         memory the object creates gets freed with object_free().
     185        Functions for creating and destroying objects should be named
     186        according to the following conventions:
     187
     188        owl_*_init: Takes a pointer to a caller-allocated struct, and
     189                creates an object there.
     190        owl_*_cleanup: Takes a pointer, and destroys the object there,
     191                expecting the caller to free the struct.
     192
     193        owl_*_new: Allocates a struct, creates an object there, and
     194                returns a pointer.
     195        owl_*_delete: Takes a pointer, destroys the object, and frees
     196                the struct.
     197
    188198        Functions should document if the caller needs to free
    189199        something, and this should be the exception to the rule.
Note: See TracChangeset for help on using the changeset viewer.