"ctx"是什么意思?

Blu*_*lub 24 c abbreviation

我已经看到它已经在不同的库中使用了两次作为缩写,但我无法理解它应该是什么意思.

例如这里:

static int reformat_string(void * ctx, const unsigned char * stringVal,  
                       size_t stringLen)  
{  
    yajl_gen g = (yajl_gen) ctx;  
    return yajl_gen_status_ok == yajl_gen_string(g, stringVal, stringLen);  
}  
Run Code Online (Sandbox Code Playgroud)

据我所知,它通常用于结构..

jam*_*lin 34

它通常代表"背景".通常这是一些传递给库中函数的结构,用于维护状态(即函数调用的上下文).

它是使用全局变量的首选替代方法.