[Pidgin] #3675: PRPLs (among others) should fill in structs allocated by the core, rather than giving the core static structs, to avoid needing padding fields or sizeof-based magic

Pidgin trac at pidgin.im
Wed Oct 24 11:45:23 EDT 2007


#3675: PRPLs (among others) should fill in structs allocated by the core, rather
than giving the core static structs, to avoid needing padding fields or
sizeof-based magic
-------------------------+--------------------------------------------------
 Reporter:  resiak       |       Owner:  resiak
     Type:  enhancement  |      Status:  new   
 Priority:  minor        |   Milestone:  3.0.0 
Component:  libpurple    |     Version:        
 Keywords:               |     Pending:  0     
-------------------------+--------------------------------------------------
 Currently, we have padding fields at the ends of structs
 (`PurplePluginProtocolInfo` and all the UiOps structs) to allow new fields
 to be added without bumping the major.  Sadly, we then run out of padding
 fields.  Sean has proposed a solution which involves turning the final
 reserved field into a `struct_size` field, with the prpl assigning
 `sizeof(PurplePluginProtocolInfo)` to this field, then adding any more
 fields after this field.  When the fields are used by libpurple, there is
 a macro which checks that their offset from the start of the struct is `<=
 struct_size`.

 This scares me, and strikes me as error-prone.  A less scary solution
 involves the core allocating the struct and passing a pointer to it to
 some `init_prpl_info` function of the prpl.  The prpl then fills in the
 relevant fields with `prpl_info->foo = my_prpl_foo`.

 This would obviously need 3.0.

-- 
Ticket URL: <http://developer.pidgin.im/ticket/3675>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list