freeswitch 源码学习
freeswitch
源码学习。
了解基本的,但又略有点要理解的c
知识
函数指针定义
typedef void(*switch_device_state_function_t)(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec);
- realloc
- strdup
了解基本 apr
知识
这个文章不错,可以先通过这篇文章整体了解下 apr
的基本知识。
函数定义
一般函数定义会分为两个部分,一个是宏,一个是真正的函数原型。
主要目的,是为了传递日志需要的函数调用的位置信息。
SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
_In_z_ const char *func, _In_ int line);
#define switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
switch_core.h
这个函数原型应该熟读
列下函数清单吧。熟读这个.h
文件,主要是,重要的代码注释都在这里了。另外,其它所有文件,几乎都要引用这个头文件的
结合这个代码注释,去理解一些核心逻辑,另外也避免再造低质量的轮子
常用函数
zstr
/*! \brief Test for NULL or zero length string \param s the string to test \return true value if the string is NULL or zero length */ _Check_return_ static inline int _zstr(_In_opt_z_ const char *s) { return !s || *s == '\0'; }