[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help on #271678 (sizefo struct?)



In article <[🔎] 20050516081733.GA12100@love.sense.znet> you wrote:
> If you happen to have a variable (or field or in fact any expression)
> of that type (either type "struct x25_address" or type "x25_address"),
> then you can take the size of the variable, instead of the size of the
> type.

Yes thats a good point, hmm:


{
  struct x25_route_struct rt;
  struct sockaddr_x25 sx25;
...
  memset((char *) &rt, 0, sizeof(struct x25_route_struct));
...
  /* x25_route_struct.address isn't type struct sockaddr_x25, Why? */
  memcpy(&rt.address, &sx25.sx25_addr, sizeof(struct x25_address));
...


The 2.6 headers include:

#struct x25_address {
#        char x25_addr[16];
#};
#
#/*
# *      Linux X.25 Address structure, used for bind, and connect mostly.
# */
#struct sockaddr_x25 {
#        sa_family_t        sx25_family;         /* Must be AF_X25 */
#        struct x25_address sx25_addr;           /* X.121 Address */
#};

and the 2.4 headers:

#typedef struct {
#        char            x25_addr[16];
#} x25_address;

#struct sockaddr_x25 {
#        sa_family_t     sx25_family;            /* Must be AF_X25 */
#        x25_address     sx25_addr;              /* X.121 Address */
#};

>    memcpy(&rt.address, &sx25.sx25_addr, sizeof sx25.sx25_addr);
> This will work with either definition of sx25_address.

thanks  for your  help, will do that (however i prefer the paranteses :)

Greetings
Bernd



Reply to: