return newstr;
}
-gchar *
-rspamd_mempool_strdup_shared (rspamd_mempool_t * pool, const gchar *src)
-{
- gsize len;
- gchar *newstr;
-
- if (src == NULL) {
- return NULL;
- }
-
- len = strlen (src);
- newstr = rspamd_mempool_alloc_shared (pool, len + 1);
- memcpy (newstr, src, len);
- newstr[len] = '\0';
-
- return newstr;
-}
-
void
rspamd_mempool_add_destructor_full (rspamd_mempool_t * pool,
rspamd_mempool_destruct_t func,
*/
void * rspamd_mempool_alloc_shared (rspamd_mempool_t * pool, gsize size);
void * rspamd_mempool_alloc0_shared (rspamd_mempool_t *pool, gsize size);
-gchar * rspamd_mempool_strdup_shared (rspamd_mempool_t * pool,
- const gchar *src);
/**
* Add destructor callback to pool
* @param pool memory pool object
g_slice_free1 (sizeof (rspamd_mutex_t), mtx);
}
-/**
- * Create new rwlock
- * @return
- */
-rspamd_rwlock_t *
-rspamd_rwlock_new (void)
-{
- rspamd_rwlock_t *new;
-
- new = g_malloc (sizeof (rspamd_rwlock_t));
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_init (&new->rwlock);
-#else
- g_static_rw_lock_init (&new->rwlock);
-#endif
-
- return new;
-}
-
-/**
- * Lock rwlock for writing
- * @param mtx
- */
-inline void
-rspamd_rwlock_writer_lock (rspamd_rwlock_t *mtx)
-{
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_writer_lock (&mtx->rwlock);
-#else
- g_static_rw_lock_writer_lock (&mtx->rwlock);
-#endif
-}
-
-/**
- * Lock rwlock for reading
- * @param mtx
- */
-inline void
-rspamd_rwlock_reader_lock (rspamd_rwlock_t *mtx)
-{
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_reader_lock (&mtx->rwlock);
-#else
- g_static_rw_lock_reader_lock (&mtx->rwlock);
-#endif
-}
-
-/**
- * Unlock rwlock from writing
- * @param mtx
- */
-inline void
-rspamd_rwlock_writer_unlock (rspamd_rwlock_t *mtx)
-{
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_writer_unlock (&mtx->rwlock);
-#else
- g_static_rw_lock_writer_unlock (&mtx->rwlock);
-#endif
-}
-
-/**
- * Unlock rwlock from reading
- * @param mtx
- */
-inline void
-rspamd_rwlock_reader_unlock (rspamd_rwlock_t *mtx)
-{
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_reader_unlock (&mtx->rwlock);
-#else
- g_static_rw_lock_reader_unlock (&mtx->rwlock);
-#endif
-}
-
-void
-rspamd_rwlock_free (rspamd_rwlock_t *mtx)
-{
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- g_rw_lock_clear (&mtx->rwlock);
-#endif
- g_slice_free1 (sizeof (rspamd_rwlock_t), mtx);
-}
-
struct rspamd_thread_data {
gchar *name;
gint id;
#endif
} rspamd_mutex_t;
-typedef struct rspamd_rwlock_s {
-#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
- GRWLock rwlock;
-#else
- GStaticRWLock rwlock;
-#endif
-} rspamd_rwlock_t;
-
/**
* Create new mutex
*/
void rspamd_mutex_free (rspamd_mutex_t *mtx);
-/**
- * Create new rwloc
- * @return
- */
-rspamd_rwlock_t * rspamd_rwlock_new (void);
-
-/**
- * Lock rwlock for writing
- * @param mtx
- */
-void rspamd_rwlock_writer_lock (rspamd_rwlock_t *mtx);
-
-/**
- * Lock rwlock for reading
- * @param mtx
- */
-void rspamd_rwlock_reader_lock (rspamd_rwlock_t *mtx);
-
-/**
- * Unlock rwlock from writing
- * @param mtx
- */
-void rspamd_rwlock_writer_unlock (rspamd_rwlock_t *mtx);
-
-/**
- * Unlock rwlock from reading
- * @param mtx
- */
-void rspamd_rwlock_reader_unlock (rspamd_rwlock_t *mtx);
-
-/**
- * Free rwlock
- * @param mtx
- */
-void rspamd_rwlock_free (rspamd_rwlock_t *mtx);
-
/**
* Create new named thread
* @param name name pattern