Creating C Library Streaming Security

I am writing a shared library in C. I know that C functions are not thread safe.

My library routines look like

struct lib_handle {
....
};

int lib_init(lib_handle **handle);
int lib_process(lib_handle *handle);
....
....

Each method takes a pointer to an object lib_handle. All state is stored inside this structure. Global variables are not used.

I assume that if each thread creates its own instances lib_handle, several threads can use library functions. Since each thread has its own descriptor, each of them should work.

I have not yet confirmed this assumption. I am wondering what you guys think of this project, and can you designate my library as thread safe, given that each thread has its own descriptors?

Any help would be great!

+5
3

/ .

, , . strtok_r strtok.

+3

. , . , lib_handle , .

+1

lib_handle, ; lib_handle, , , - , (.. , , , , ).

(shared lib_handle) , , lib_handle , lib_handle. , - ( ).

Why should you use the template that you describe quite a lot, and he likes it.

0
source

All Articles