Skip to content

core: revert removed explicit init & add missing init

Lyndon Brown requested to merge jnqnfe/vlc:initrevert into master
  • vlc_stream_CustomNew() uses vlc_custom_create() which uses calloc().
  • vlc_stream_CustomNew() additionally initialised most attributes to NULL/0/false (some were missing).
  • Functions using vlc_stream_CustomNew() further such initialised some attributes.

Patches removing the explicit initialisation (because I felt it was redundant) got merged in !1104 (merged) from a last minute addition that got overlooked. A revert of these patches has been requested (see !1104 (merged) discussion).

The basis for reverting is because explicit initialisation is preferred even if redundant. There is a portability issue at play here. The C standard says that an "integral constant expression" of 0 assigned to or compared with a pointer is interpreted as being a null pointer. Thus ptr = 0 means set to a null pointer and ptr == 0 compares with a null pointer, which we often do indirectly via the NULL define, but this does not mean that a null pointer is necessarily a memory address of zero which is up to the underlying platform to decide. A call to calloc() or memset(ptr, 0, n) guarantee that memory is set to zero. Portably, use of those functions cannot be considered to correctly initialise pointers to be null pointers, just as is the same for correctly initialising floats/doubles to a value of 0.0 which is not necessarily an all-zero-bit pattern.

  • The first commit reverts b10f5a02, restoring the (actually redundant) init done by users of vlc_stream_CustomNew().
  • The second commit reverts 830ea36e, restoring the explicit init done by vlc_stream_CustomNew().
  • The third commit adds missing attributes to the set vlc_stream_CustomNew() explicitly initialises to make the explicit init complete.
Edited by Lyndon Brown

Merge request reports

Loading