[Openmcl-cvs-notifications] r10464 - /trunk/source/lisp-kernel/thread_manager.c

gb at clozure.com gb at clozure.com
Wed Aug 13 18:42:45 EDT 2008


Author: gb
Date: Wed Aug 13 18:42:45 2008
New Revision: 10464

Log:
Call pthread_attr_destroy() on pthread_attr objects when done with
them.  (Even though the pthread_attr objects are stack-allocated,
they may contain malloc'ed data when initialized.)

In destroy_semaphore(), free the malloc'ed semaphore in the
USE_POSIX_SEMAPHORES case (after calling sem_destroy().)

Modified:
    trunk/source/lisp-kernel/thread_manager.c

Modified: trunk/source/lisp-kernel/thread_manager.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/thread_manager.c (original)
+++ trunk/source/lisp-kernel/thread_manager.c Wed Aug 13 18:42:45 2008
@@ -467,6 +467,7 @@
 =

   pthread_getattr_np(p,&attr);
   pthread_attr_getstack(&attr, base, size);
+  pthread_attr_destroy(&attr);
   *(natural *)base +=3D *size;
 #endif
 #ifdef FREEBSD
@@ -481,6 +482,7 @@
   pthread_attr_getstacksize(&attr,&temp_size);
   *base =3D (void *)((natural)temp_base + temp_size);
   *size =3D temp_size;
+  pthread_attr_destroy(&attr);
 #endif
 #ifdef SOLARIS
   stack_t st;
@@ -548,6 +550,7 @@
   if (*s) {
 #ifdef USE_POSIX_SEMAPHORES
     sem_destroy((sem_t *)*s);
+    free(*s);
 #endif
 #ifdef USE_MACH_SEMAPHORES
     semaphore_destroy(mach_task_self(),((semaphore_t)(natural) *s));
@@ -1237,6 +1240,7 @@
      I think that's just about enough ... create the thread.
   */
   pthread_create(&returned_thread, &attr, start_routine, param);
+  pthread_attr_destroy(&attr);
   return (LispObj) ptr_to_lispobj(returned_thread);
 }
 #endif



More information about the Openmcl-cvs-notifications mailing list