neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34900?usp=email )
Change subject: add fmtp string to ptmap: allow all possible fmtp ......................................................................
Patch Set 3:
(3 comments)
File include/osmocom/mgcp/mgcp_network.h:
https://gerrit.osmocom.org/c/osmo-mgw/+/34900/comment/26f6967e_d57f2eb6 PS3, Line 90: char fmtp[256];
here is that char fmtp[256], it matches the storage choice of audio_name[] above.
context: this is used in public API, also as out-parameter. Dynamic allocation would be tricky, so leave it static.
File include/osmocom/mgcp_client/mgcp_client.h:
https://gerrit.osmocom.org/c/osmo-mgw/+/34900/comment/ae818ca6_8024f899 PS3, Line 84: const char *fmtp;
I'm a bit wobbly on the storage choice. Elsewhere I put a char fmtp[256]. […]
context: structs with ptmap members are: - struct mgcp_conn_peer - struct mgcp_response
If a fmtp is only passed in as function arg, it is fine to be a static pointer that goes bust after the function returns. For persistent storage, a pointer going bust would be bad. So are any of these structs persistent?
mgcp_conn_peer is stored persistently in at least mgcp_client_endpoint_fsm.c.
It copies a value passed in from a caller outside of this library.
So indeed a static array would be safer / simpler here.
File src/libosmo-mgcp/mgcp_sdp.c:
https://gerrit.osmocom.org/c/osmo-mgw/+/34900/comment/8333a45b_d2dc732c PS3, Line 59: const char *fmtp;
here's another dynamic string...
context: this struct is used only internally in this .c file. The storage is never persistent, always limited in a function scope. There already is a bunch of talloc allocation with a temporary ctx, so this is fine to remain a pointer (and not impose a length limit).