Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: moved function declarations to external file header

...

Code Block
bgColor#ccccff
struct string_mx;
typedef struct string_mx string_mx;

/* Function declarations */
extern errno_t strcpy_m(string_mx *s1, const string_mx *s2);
extern errno_t strcat_m(string_mx *s1, const string_mx *s2) ;
/* etc. */

In the internal header file, struct string_mx is fully defined but not visible to a user of the data abstraction.

Code Block
bgColor#ccccff
struct string_mx {
    size_t size;
    size_t maxsize;
    unsigned char strtype;
    char *cstr;
};

/* Function declarations */
extern errno_t strcpy_m(string_mx *s1, const string_mx *s2);
extern errno_t strcat_m(string_mx *s1, const string_mx *s2) ;
/* etc. */

Modules that implement the abstract data type include both the external and internal definitions, while users of the data abstraction include only the external string_m.h file. This allows the implementation of the string_mx data type to remain private.

...