~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_thr_init.cc

  • Committer: Brian Aker
  • Date: 2009-08-03 06:08:05 UTC
  • mfrom: (1106.1.5 memory-fix)
  • Revision ID: brian@gaz-20090803060805-fqaa2t3jejgwhwu2
Collection of Valgrind fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
 
170
170
bool my_thread_init(void)
171
171
{
172
 
  struct st_my_thread_var *tmp;
173
172
  bool error=0;
 
173
  st_my_thread_var *tmp= NULL;
174
174
 
175
175
#ifdef EXTRA_DEBUG_THREADS
176
176
  fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n",
185
185
#endif
186
186
    goto end;
187
187
  }
188
 
  if (!(tmp= (struct st_my_thread_var *) calloc(1, sizeof(*tmp))))
 
188
  tmp= static_cast<st_my_thread_var *>(calloc(1, sizeof(*tmp)));
 
189
  if (tmp == NULL)
189
190
  {
190
191
    error= 1;
191
192
    goto end;
220
221
 
221
222
void my_thread_end(void)
222
223
{
223
 
  struct st_my_thread_var *tmp;
224
 
  tmp= (struct st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
 
224
  st_my_thread_var *tmp=
 
225
    static_cast<st_my_thread_var *>(pthread_getspecific(THR_KEY_mysys));
225
226
 
226
227
#ifdef EXTRA_DEBUG_THREADS
227
228
  fprintf(stderr,"my_thread_end(): tmp: 0x%lx  pthread_self: 0x%lx  thread_id: %ld\n",
234
235
    pthread_cond_destroy(&tmp->suspend);
235
236
#endif
236
237
    pthread_mutex_destroy(&tmp->mutex);
237
 
    tmp->init= 0;
 
238
    free(tmp);
238
239
 
239
240
    /*
240
241
      Decrement counter for number of running threads. We are using this
246
247
    assert(THR_thread_count != 0);
247
248
    if (--THR_thread_count == 0)
248
249
      pthread_cond_signal(&THR_COND_threads);
249
 
   pthread_mutex_unlock(&THR_LOCK_threads);
 
250
    pthread_mutex_unlock(&THR_LOCK_threads);
250
251
  }
251
252
}
252
253