You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GOMEZ Henri <hg...@slib.fr> on 2001/07/05 09:33:03 UTC

[J-T-C] struct defs

We found many definitions like this 
in mod_jk :

xxx.h

struct jk_map;
typedef struct jk_map jk_map_t;

xxx.c

struct jk_map {
    jk_pool_t p;
    jk_pool_atom_t buf[SMALL_POOL_SIZE];

    char **names;
    void **values;

    unsigned capacity;
    unsigned size;
};

Why not having it directly in xxx.h 

typedef struct {
    jk_pool_t p;
    jk_pool_atom_t buf[SMALL_POOL_SIZE];

    char **names;
    void **values;

    unsigned capacity;
    unsigned size;
} jk_map_t;


-
Henri Gomez                 ___[_]____
EMAIL : hgomez@slib.fr        (. .)                     
PGP KEY : 697ECEDD    ...oOOo..(_)..oOOo...
PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 

Re: [J-T-C] struct defs

Posted by Andy Armstrong <an...@tagish.com>.
The reason would be to keep the implementation details of the structure
private so that people aren't tempted to access the fields directly. All
the caller gets is an opaque handle. Think of it as 'objects lite' for
C.

GOMEZ Henri wrote:
> 
> We found many definitions like this
> in mod_jk :
> 
> xxx.h
> 
> struct jk_map;
> typedef struct jk_map jk_map_t;
> 
> xxx.c
> 
> struct jk_map {
>     jk_pool_t p;
>     jk_pool_atom_t buf[SMALL_POOL_SIZE];
> 
>     char **names;
>     void **values;
> 
>     unsigned capacity;
>     unsigned size;
> };
> 
> Why not having it directly in xxx.h
> 
> typedef struct {
>     jk_pool_t p;
>     jk_pool_atom_t buf[SMALL_POOL_SIZE];
> 
>     char **names;
>     void **values;
> 
>     unsigned capacity;
>     unsigned size;
> } jk_map_t;
> 
> -
> Henri Gomez                 ___[_]____
> EMAIL : hgomez@slib.fr        (. .)
> PGP KEY : 697ECEDD    ...oOOo..(_)..oOOo...
> PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6

-- 
Andy Armstrong, Tagish