| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #ifndef __SHM_MEM_H__
- #define __SHM_MEM_H__
- #pragma once
- #include "config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdarg.h>
- #define SHM_MEM_SIZE 16 /* MB */
- TOOLKIT_API int shm_getmem(int key, void** hint);
- TOOLKIT_API int shm_mem_init2(int key, void *hint, int newcreate);
- TOOLKIT_API void shm_mem_destroy();
- TOOLKIT_API char *shm_strdup(const char *str);
- TOOLKIT_API char *shm_strdup_printf(const char *format, ...);
- TOOLKIT_API char *shm_strdup_vprintf(const char *format, va_list args);
- TOOLKIT_API void shm_lock();
- TOOLKIT_API void shm_unlock();
- //
- TOOLKIT_API void shm_set_user_data(int idx, void *user_data);
- TOOLKIT_API void *shm_get_user_data(int idx);
- TOOLKIT_API void *shm_malloc_unsafe(unsigned int size);
- TOOLKIT_API void* shm_malloc(unsigned int size);
- TOOLKIT_API void shm_free_unsafe(void *_p);
- #define shm_free(_p) \
- do { \
- shm_lock(); \
- shm_free_unsafe( _p ); \
- shm_unlock(); \
- }while(0)
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__SHM_MEM_H__
|