[Ada] As we use the default behavior, no need to allocate a cond attribute
Arnaud Charlet
charlet@adacore.com
Mon Nov 21 12:00:00 GMT 2011
Passing a null pointer to pthread_cond_init for the attribute specify
that the default attribute should be used. This is exactly what was done
previously by using a cond attribute with default value.
This is just a code clean-up, no change in behavior but we avoid some
system calls and furthermore the cond attribute was not destroyed
properly which could cause resource/memory leaks.
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-11-21 Pascal Obry <obry@adacore.com>
* s-taprop-linux.adb (Initialize_Lock): Do not allocate a cond
attribute as not needed.
-------------- next part --------------
Index: s-taprop-linux.adb
===================================================================
--- s-taprop-linux.adb (revision 181564)
+++ s-taprop-linux.adb (working copy)
@@ -1069,8 +1069,7 @@
----------------
procedure Initialize (S : in out Suspension_Object) is
- Cond_Attr : aliased pthread_condattr_t;
- Result : Interfaces.C.int;
+ Result : Interfaces.C.int;
begin
-- Initialize internal state (always to False (RM D.10(6)))
@@ -1090,11 +1089,8 @@
-- Initialize internal condition variable
- Result := pthread_condattr_init (Cond_Attr'Access);
- pragma Assert (Result = 0);
+ Result := pthread_cond_init (S.CV'Access, null);
- Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access);
-
pragma Assert (Result = 0 or else Result = ENOMEM);
if Result /= 0 then
More information about the Gcc-patches
mailing list