This is recommended:
/* ** my_strlen: "strlen" equivalent ** str: the string ** return value: the number of characters ** my_strlen counts the number of characters in [str], not ** counting the final '\0' character. */ size_t my_strlen(const char *str); { /* definition of my_strlen */ } |
Rationale: function bodies should be kept short.
For example:
void *xmalloc(size_t n) { void *p; p = malloc(n); if (p == 0) { fprintf(stderr, "Virtual memory exhausted.\n"); exit(1); } return p; } |