otrv4 / libotr-ng

A new implementation of OTR with support for version 4. This is a mirror of https://bugs.otr.im/otrv4/libotr-ng
Other
43 stars 9 forks source link

Remove most of our _p typedefs #160

Closed olabini closed 6 years ago

olabini commented 6 years ago

libgoldilocks uses a pattern of "manifest array" typedefs for structures. Basically, a typedef is added for a struct that has a one element member. Something like this:

typedef struct foo_s {
} foo_s, foo_p[1];

There are two different positive reasons for using this pattern. First, when using a struct inside of another struct, if the member is one of these manifest arrays the struct will have its storage fully embedded inside of the enclosing struct, while still making it very clean to send the struct (and not a copy of it) as argument to functions. The other benefit is that when using the struct inside of a function, storage will automatically be allocated and deallocated, without explicit mallocs and frees.

These reasons are good for the purpose of the libgoldilocks primitives, primarily the goldilocks_448_point_p and goldilocks_448_scalar_p types. However, for libotr-ng, we have ended up with a LOT of places using this pattern as well, which doesn't work so well for a few reasons:

So, in order to fix this, this is the plan for how we will handle structs inside libotr-ng:

olabini commented 6 years ago

This is fixed now. including changing the plugin as well.