/** * @brief Allocate a new mps_context struct with default * options. */ mps_context * mps_context_new () { mps_context * ctx = NULL; /* Try to get a low cost context from the factory */ pthread_mutex_lock (&context_factory_mutex); if (context_factory_size > 0) { /* Pop out a context */ ctx = context_factory[--context_factory_size]; if (context_factory_size) context_factory = mps_realloc (context_factory, sizeof(mps_context*) * context_factory_size); else { free (context_factory); context_factory = NULL; } } pthread_mutex_unlock (&context_factory_mutex); /* Allocate the new mps_context and load default options */ if (!ctx) { ctx = (mps_context*)mps_malloc (sizeof(mps_context)); mps_context_init (ctx); } return ctx; }
/** * @brief Allocate a new mps_context struct with default * options. */ mps_context * mps_context_new () { /* Allocate the new mps_context and load default options */ mps_context * s = (mps_context*) mps_malloc (sizeof (mps_context)); mps_context_init (s); return s; }