Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed possible memory leaks

  • Loading branch information...
commit ddb316e33634de633c65de0561fffa559f1ee20e 1 parent 19e53e2
Felix Krause authored May 31, 2012
4  src/gl/implementation/gl-objects-programs.adb
@@ -54,7 +54,9 @@ package body GL.Objects.Programs is
54 54
          API.Get_Program_Info_Log (Subject.Reference.GL_Id,
55 55
                                    Low_Level.SizeI (Log_Length),
56 56
                                    Actual_Length, C_Info_Log);
57  
-         return C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
  57
+         Info_Log := C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
  58
+         C.Strings.Free (C_Info_Log);
  59
+         return Info_Log;
58 60
       end;
59 61
    end Info_Log;
60 62
 
15  src/gl/implementation/gl-objects-shaders.adb
@@ -37,8 +37,7 @@ package body GL.Objects.Shaders is
37 37
       API.Get_Shader_Param (Subject.Reference.GL_Id,
38 38
                             Enums.Shader_Source_Length, Source_Length);
39 39
       declare
40  
-         Shader_Source : String (1 .. Integer (Source_Length))
41  
-           := (others => ' ');
  40
+         Shader_Source : String (1 .. Integer (Source_Length));
42 41
          C_Shader_Source : C.Strings.chars_ptr
43 42
            := C.Strings.New_String (Shader_Source);
44 43
          Actual_Length : Low_Level.SizeI;
@@ -46,7 +45,10 @@ package body GL.Objects.Shaders is
46 45
          API.Get_Shader_Source (Subject.Reference.GL_Id,
47 46
                                 Low_Level.SizeI (Source_Length),
48 47
                                 Actual_Length, C_Shader_Source);
49  
-         return C.Strings.Value (C_Shader_Source, C.size_t (Actual_Length));
  48
+         Shader_Source
  49
+           := C.Strings.Value (C_Shader_Source, C.size_t (Actual_Length));
  50
+         C.Strings.Free (C_Shader_Source);
  51
+         return Shader_Source;
50 52
       end;
51 53
    end Source;
52 54
 
@@ -69,8 +71,7 @@ package body GL.Objects.Shaders is
69 71
       API.Get_Shader_Param (Subject.Reference.GL_Id,
70 72
                             Enums.Info_Log_Length, Log_Length);
71 73
       declare
72  
-         Info_Log : String (1 .. Integer (Log_Length))
73  
-           := (others => ' ');
  74
+         Info_Log : String (1 .. Integer (Log_Length));
74 75
          C_Info_Log : C.Strings.chars_ptr
75 76
            := C.Strings.New_String (Info_Log);
76 77
          Actual_Length : Low_Level.SizeI;
@@ -78,7 +79,9 @@ package body GL.Objects.Shaders is
78 79
          API.Get_Shader_Info_Log (Subject.Reference.GL_Id,
79 80
                            Low_Level.SizeI (Log_Length),
80 81
                            Actual_Length, C_Info_Log);
81  
-         return C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
  82
+         Info_Log := C.Strings.Value (C_Info_Log, C.size_t (Actual_Length));
  83
+         C.Strings.Free (C_Info_Log);
  84
+         return Info_Log;
82 85
       end;
83 86
    end Info_Log;
84 87
    

0 notes on commit ddb316e

Please sign in to comment.
Something went wrong with that request. Please try again.