ref: 381a7bd0e2bbe4838cc59f9220eaecaa46b6a303
parent: 88eec9c75d0a23c6c4d5d61af76c6ebd56b82b51
author: Doug Cook <idigdoug@users.sourceforge.net>
date: Sun Mar 27 20:39:50 EDT 2011
Remove globals from sox.h Remove global variables from public SoX API. Globals have been replaced with functions that return pointers to the requested object. Back-compat macros defined, i.e. sox_globals is defined as (*sox_get_globals()). - Temporarily moved sox_effects_globals definition into libsox so it can see the static address of sox_globals for its own static initialization. Add compiler decorations SOX_API and LSX_RETURN_PURE: - All functions and function pointers are declared as SOX_API, which declares that all SoX functions use the same calling convention regardless of the compiler's settings, i.e. to override GCC's -mrtd switch or MSVC's -Gz or -Gr switches. Supported for MSVC and GCC. - Functions that always return the same value (such as sox_get_globals()) are decorated as pure. Supported only by GCC. Add semantic decorations to pointer return types and parameters. The decorations optionally use "SAL" annotations, which can be used for static analysis. If SAL is not available, the decorations are nothing more than documentation for the reader. - All functions that return pointers are decorated to indicate whether the returned pointer can be NULL. - All pointer parameters are decorated to indicate whether the pointer can be NULL, whether the buffer is input/output/inout, and to describe buffer sizes. Rename lsx_output functions to lsx_output_impl to avoid macro confusion. Fix some warnings found by code analysis: - Avoid hiding variables. Rename local variables that conflict with variables in enclosing scopes. - Verify 0-termination after strncpy. - Parameters to isdigit must be cast to unsigned char. Signed chars less than 0 are considered negative and cause isdigit to malfunction. TODO: - Globals from getopt are still being imported from libsox.dll to sox.exe, even though getopt is not published in sox.h. - Once getopt is resolved, move from export-everything to exporting a specific list of functions (DEF file for Windows, ??? for other platforms). - This change still doesn't make SoX thread safe -- the globals are still there. This is just the first step. Later steps will include adding an opaque sox_t parameter to all non-thread-safe functions.