procedure Free (Item : in out chars_ptr) is
begin
- if Item = Null_Ptr then
- return;
+ if Item /= Null_Ptr then
+ Memory_Free (Item);
+ Item := Null_Ptr;
end if;
-
- Memory_Free (Item);
- Item := Null_Ptr;
end Free;
--------------------
function Position_Of_Nul (Into : char_array) return size_t is
begin
+ pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+ "early returns for performance");
for J in Into'Range loop
if Into (J) = nul then
return J;
end loop;
return Into'Last + 1;
+
+ pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
end Position_Of_Nul;
------------
Nul_Check : Boolean := False) return chars_ptr
is
begin
+ pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+ "early returns for performance");
if Item = null then
return Null_Ptr;
elsif Nul_Check
else
return To_chars_ptr (Item (Item'First)'Address);
end if;
+
+ pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
end To_Chars_Ptr;
------------
Length : size_t) return char_array
is
begin
+ pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+ "early returns for performance");
if Item = Null_Ptr then
raise Dereference_Error;
end if;
return Result;
end;
+
+ pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
end Value;
function Value (Item : chars_ptr) return String is
Result : char_array (0 .. Length);
begin
+ pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+ "early returns for performance");
-- As per AI-00177, this is equivalent to:
-- To_Ada (Value (Item, Length) & nul);
Result (Length) := nul;
return To_Ada (Result);
+
+ pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
end Value;
end Interfaces.C.Strings;