Permalink
Browse files

Fixed possible memory leaks

  • Loading branch information...
1 parent 19e53e2 commit ddb316e33634de633c65de0561fffa559f1ee20e @flyx committed May 31, 2012
Showing with 12 additions and 7 deletions.
  1. +3 −1 src/gl/implementation/gl-objects-programs.adb
  2. +9 −6 src/gl/implementation/gl-objects-shaders.adb
@@ -54,7 +54,9 @@ package body GL.Objects.Programs is
API.Get_Program_Info_Log (Subject.Reference.GL_Id,
Low_Level.SizeI (Log_Length),
Actual_Length, C_Info_Log);
- return C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
+ Info_Log := C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
+ C.Strings.Free (C_Info_Log);
+ return Info_Log;
end;
end Info_Log;
@@ -37,16 +37,18 @@ package body GL.Objects.Shaders is
API.Get_Shader_Param (Subject.Reference.GL_Id,
Enums.Shader_Source_Length, Source_Length);
declare
- Shader_Source : String (1 .. Integer (Source_Length))
- := (others => ' ');
+ Shader_Source : String (1 .. Integer (Source_Length));
C_Shader_Source : C.Strings.chars_ptr
:= C.Strings.New_String (Shader_Source);
Actual_Length : Low_Level.SizeI;
begin
API.Get_Shader_Source (Subject.Reference.GL_Id,
Low_Level.SizeI (Source_Length),
Actual_Length, C_Shader_Source);
- return C.Strings.Value (C_Shader_Source, C.size_t (Actual_Length));
+ Shader_Source
+ := C.Strings.Value (C_Shader_Source, C.size_t (Actual_Length));
+ C.Strings.Free (C_Shader_Source);
+ return Shader_Source;
end;
end Source;
@@ -69,16 +71,17 @@ package body GL.Objects.Shaders is
API.Get_Shader_Param (Subject.Reference.GL_Id,
Enums.Info_Log_Length, Log_Length);
declare
- Info_Log : String (1 .. Integer (Log_Length))
- := (others => ' ');
+ Info_Log : String (1 .. Integer (Log_Length));
C_Info_Log : C.Strings.chars_ptr
:= C.Strings.New_String (Info_Log);
Actual_Length : Low_Level.SizeI;
begin
API.Get_Shader_Info_Log (Subject.Reference.GL_Id,
Low_Level.SizeI (Log_Length),
Actual_Length, C_Info_Log);
- return C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
+ Info_Log := C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
+ C.Strings.Free (C_Info_Log);
+ return Info_Log;
end;
end Info_Log;

0 comments on commit ddb316e

Please sign in to comment.