Re: gpointer question



As a good programming practice, if you keep a gpointer (void *) to the struct
in your typModel, should also have a enumeration which is says what kind of
strut is stored in the "modeldata" pointer. This is because C doesn't really
have that kind of type checking when you are converting back from "void */gpointer" back to the structure. 
Some changes I suggest.


+ enum ModelDataType {
+        TYPE_SHIP,
+        TYPE_FOO,
+        TYPE_BAR
+ };


typedef struct {
        int  model_id;
        int  active;
        int  units;
        typGeometry  geodata;
+       ModelDataType modeltype;
        gpointer  modeldata;
} typModel;

typdef struct {
        float length;
        float lwl;
        float beam;
        float draft;
        float depth;
} typShip;

Just a thought
Archit Baweja



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