Commits

Anonymous committed 2ded584

free SDL objects on malloc errors

  • Participants
  • Parent commits f0e1afe

Comments (0)

Files changed (5)

 # BREAK = change breaks existing code
 # BUG   = fixed a bug that was crashing
 
+Apr 08, 2001
+	properly free SDL objects on malloc errors
+
 pygame-10
 Apr 05, 2001
 	Everything set for the 1.0 release
 	RETURN_NONE
 }
 
+static PyObject* gl_swap_buffers(PyObject* self, PyObject* arg)
+{
+    if(!PyArg_ParseTuple(arg, ""))
+        return NULL;
+
+    VIDEO_INIT_CHECK();
+
+    SDL_GL_SwapBuffers();
+
+    RETURN_NONE
+}
+
 
 static PyMethodDef display_builtins[] =
 {
 
 	{ "testgl1", testgl1, 1, NULL },
 	{ "testgl2", testgl2, 1, NULL },
+{ "gl_swap_buffers", gl_swap_buffers, 1, NULL },
 
 	{ NULL, NULL }
 };
 		return RAISE(PyExc_RuntimeError, "unable to load font.");
 
 	fontobj = PyObject_NEW(PyFontObject, &PyFont_Type);
-	if(!fontobj)
-		return NULL;
+	if(fontobj)
+	{
+		fontobj->font = font;
+	}
+	else
+	{
+		/*free the original font, nobody else can*/
+		TTF_CloseFont(font); 
+	}
 
-	fontobj->font = font;
 	return (PyObject*)fontobj;
 }
 
 		return RAISE(PyExc_RuntimeError, "unable to create sound.");
 
 	soundobj = PyObject_NEW(PySoundObject, &PySound_Type);
-	if(!soundobj)
-		return NULL;
+	if(soundobj)
+	{
+		soundobj->chunk = chunk;
+	}
+	else
+	{
+		/*free the sound here, nobody else can*/
+		Mix_FreeChunk(chunk);
+	}
 
-	soundobj->chunk = chunk;
 	return (PyObject*)soundobj;
 }
 
 		surf->didlock = 0;
 		surf->lockcount = 0;
 	}
+	else
+	{
+		/*free the surface here, because no one else can*/
+		SDL_FreeSurface(s);
+	}
 	return (PyObject*)surf;
 }