Wireshark mailing list archives
Help with pointer to unions
From: Alex Lindberg <alindber () yahoo com>
Date: Mon, 18 Apr 2011 09:09:55 -0700 (PDT)
I am working on a dissector that is version dependent. I have created a union that contains the structs of both versions: typedef struct _proto_struct { STRUCT_1 s1; STRUCT_2 s2;} s_t;s_t *s; Memory for s is created based on version and sizeof(s1) or sizeof(s2). Thus, to reference V1 it would be s->s1, V2 would bes->s2. Both s1 and s2 have much in common. I would like to create a single pointer ptr, that would point to s1 or s2 as necessary that would be used to simplify the access to the structs without having to specifically cast ptr to the struct. How could this be done? Thanks as always.Alex Lindberg
___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Help with pointer to unions Alex Lindberg (Apr 18)
- Re: Help with pointer to unions Stephen Fisher (Apr 18)
- Re: Help with pointer to unions Alex Lindberg (Apr 18)
- Re: Help with pointer to unions Guy Harris (Apr 18)
- Re: Help with pointer to unions Jaap Keuter (Apr 18)
- Re: Help with pointer to unions Alex Lindberg (Apr 18)
- Re: Help with pointer to unions Stephen Fisher (Apr 18)