/* {{{ free state object */ void pthreads_state_free(pthreads_state state TSRMLS_DC) { if (state) { pthreads_lock_free(state->lock TSRMLS_CC); pthreads_synchro_free(state->synchro TSRMLS_CC); free(state); } } /* }}} */
/* {{{ allocate (and initialize) a synchronization object */ pthreads_synchro pthreads_synchro_alloc(TSRMLS_D) { pthreads_synchro sync = (pthreads_synchro) calloc(1, sizeof(*sync)); if (sync) { if ((sync->lock = pthreads_lock_alloc(TSRMLS_C))) { if (pthread_cond_init(&sync->notify, NULL)==SUCCESS) { return sync; } pthreads_lock_free(sync->lock TSRMLS_CC); } free(sync); } return NULL; } /* }}} */