Commits

Anonymous committed 00db689

Minor code cleanups and pointer fixes.

Comments (0)

Files changed (15)

 	@$(PYTHON) setup.py build #-c mingw32
 	@echo "Build finished, invoke 'make install' to install."
 
+clang: clean
+	@echo "Running build with Clang..."
+	@$(PYTHON) setup.py build -c clang
+	@echo "Build finished, invoke 'make install' to install."
+
 install:
 	@echo "Installing..."
 	@$(PYTHON) setup.py install 

src/freetype/ft_wrap.h

 int         PGFT_TryLoadFont_Filename(FreeTypeInstance *, 
                 PyFreeTypeFont *, const char *, int);
 
-#ifdef HAVE_PYGAME_SDL_RWOPS
-int         PGFT_TryLoadFont_RWops(FreeTypeInstance *, 
-                PyFreeTypeFont *, SDL_RWops *, int);
-#endif
+int         PGFT_TryLoadFont_Stream (FreeTypeInstance *ft, 
+    PyFreeTypeFont *font, CPyStreamWrapper *wrapper, int face_index);
 
 void        PGFT_UnloadFont(FreeTypeInstance *, PyFreeTypeFont *);
 
 static PyObject*
 _mask_convolve (PyObject* self, PyObject* args)
 {
-    PyObject *pt = NULL, *cmask, *outmask = NULL;
+    PyObject *pt = NULL, *cmask = NULL, *outmask = NULL;
     bitmask_t *a, *b, *o;
     int x = 0, y = 0;
 
             return NULL;
     }
     
-    if (cmask && !PyMask_Check (cmask))
+    if (!PyMask_Check (cmask))
     {
         PyErr_SetString (PyExc_TypeError, "mask must be a Mask");
         return NULL;
 
     Py_BEGIN_ALLOW_THREADS;
 
-    pixels = (Uint8 *) surf->pixels;
     format = surf->format;
     amask = format->Amask;
     ashift = format->Ashift;
     PyMask *maskobj;
     bitmask_t* m;
     SDL_Surface* surf, *surf2;
-    int bpp;
     PyObject *rgba_obj_color, *rgba_obj_threshold;
     Uint32 color;
     Uint32 color_threshold;
         color_threshold = SDL_MapRGBA (surf->format, 0, 0, 0, 255);
     }
 
-    bpp = surf->format->BytesPerPixel;
     m = bitmask_create(surf->w, surf->h);
     if (!m)
     {
     Uint8 r, g, b, a;
     Uint8 tr, tg, tb, ta;
 
-    pixels = (Uint8 *) surf->pixels;
     format = surf->format;
     rmask = format->Rmask;
     gmask = format->Gmask;
         rloss2 = format2->Rloss;
         gloss2 = format2->Gloss;
         bloss2 = format2->Bloss;
-        pixels2 = (Uint8 *) surf2->pixels;
         bpp2 = format2->BytesPerPixel;
     }
     else
         rshift2 = gshift2 = bshift2 = 0;
         rloss2 = gloss2 = bloss2 = 0;
         format2 = NULL;
-        pixels2 = NULL;
         bpp2 = 0;
     }
 
     {
         v = (PyVector *) o1;
         other = o2;
-        vcoords = v->coords;
     }
     else if (PyVector_Check (o2))
     {
 {
     ALCchar tmp[4096] = { '\0' };
     int i = 0;
-    const ALCchar *dptr, *start;
+    const ALCchar *dptr;
     PyObject *list, *item;
     const ALCchar *devices = alcGetString (PyDevice_AsDevice (self),
         ALC_CAPTURE_DEVICE_SPECIFIER);
     if (SetALErrorException (alGetError ()))
         return NULL;
     list = PyList_New (0);
-    start = dptr = devices;
+    dptr = devices;
     while (*dptr)
     {
         if (*dptr == ' ') /* list entry end */

src/openal/openalmod.c

 #endif
 {
     PyObject *mod;
+    PyObject *c_api_obj;
+    static void *c_api[PYGAME_OPENAL_SLOTS];
 
 #ifdef IS_PYTHON_3
     static struct PyModuleDef _module = {
     
     ADD_OBJ_OR_FAIL (mod, "Device", PyDevice_Type, fail);
     ADD_OBJ_OR_FAIL (mod, "Context", PyContext_Type, fail);
+
+    device_export_capi (c_api);
+    context_export_capi (c_api);
+
+    c_api_obj = PyCObject_FromVoidPtr ((void *) c_api, NULL);
+    if (c_api_obj)
+    {
+        if (PyModule_AddObject (mod, PYGAME_OPENAL_ENTRY, c_api_obj) == -1)
+        {
+            Py_DECREF (c_api_obj);
+            goto fail;
+        }
+    }
+
     MODINIT_RETURN(mod);
 fail:
     Py_XDECREF (mod);

src/openal/openalmod.h

 #define CLEAR_ERROR_STATE() alGetError()
 
 void device_export_capi (void **capi);
+void context_export_capi (void **capi);
 
 #endif /* _PYGAME_OPENALMOD_H_ */
     struct jpeg_error_mgr jerr;
     struct dest_mgr *dest;
     JSAMPROW row_pointer[1];
-    int row_stride;
 
     cinfo.err = jpeg_std_error (&jerr);
     jpeg_create_compress (&cinfo);
     dest->pub.next_output_byte = NULL;
 
     jpeg_start_compress (&cinfo, TRUE);
-    row_stride = image_width * 3;
 
     while (cinfo.next_scanline < cinfo.image_height)
     {
     SDL_Surface *ss_surface;
     SDL_Rect ss_rect;
     int r, i;
-    int alpha = 0;
     int pixel_bits = 32;
 
     if (!surface)
     ss_w = surface->w;
     ss_h = surface->h;
 
-    alpha = 0;
     pixel_bits = 24;
 
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN

src/sdl/surface_fill.c

         result = surface_fill_blend_avg (surface, rect, color);
         break;
     }
-    
+
     case BLEND_RGBA_ADD:
     {
         result = surface_fill_blend_rgba_add (surface, rect, color);
         break;
     }
     }
+
+    if (locked)
+        SDL_UnlockSurface (surface);
+
     return result;
 }

src/sdlext/scrap_x11.c

     Atom target)
 {
     char *value = NULL;
-    _ClipData *data;
+    _ClipData *data = NULL;
     int i, size = (sizeof (datalist) / sizeof (datalist[0]));
 
     for (i = 0; i < size; i++)

src/sdlext/transform.c

 pyg_transform_flip (SDL_Surface *surface, int xaxis, int yaxis)
 {
     int loopx, loopy;
-    int pixsize, srcpitch, dstpitch;
+    int srcpitch, dstpitch;
     Uint8 *srcpix, *dstpix;
     SDL_Surface *newsurface;
 
         return NULL;
     }
 
-    pixsize = surface->format->BytesPerPixel;
     srcpitch = surface->pitch;
     dstpitch = newsurface->pitch;
     srcpix = (Uint8*) surface->pixels;
         return NULL;
     }
     
-    pixels = (Uint8 *) srcsurface->pixels;
     format = srcsurface->format;
     height = srcsurface->h;
     width = srcsurface->w;

src/sdlext/transformmod.c

     ARGB2FORMAT (diffcolor, srcsurface->format);
     ARGB2FORMAT (threscolor, srcsurface->format);
 
-    if (srcsurface->w != dstsurface->w || srcsurface->h != dstsurface->h)
+    if (dstsurface &&
+        (srcsurface->w != dstsurface->w || srcsurface->h != dstsurface->h))
     {
         PyErr_SetString (PyExc_ValueError,
             "destination surface and source surface must have the same size");
         return NULL;
     }
+
     if (diffsurface &&
         (srcsurface->w != diffsurface->w || srcsurface->h != diffsurface->h))
     {

src/sdlgfx/primitivesmod.c

 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OOOO:aaline", &surface, &p1, &p2, color))
+    if (!PyArg_ParseTuple (args, "OOOO:aaline", &surface, &p1, &p2, &color))
     {
         PyErr_Clear ();
         if (!PyArg_ParseTuple (args, "OiiiiO:aaline", &surface, &x1, &_y1,
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OOOO:line", &surface, &p1, &p2, color))
+    if (!PyArg_ParseTuple (args, "OOOO:line", &surface, &p1, &p2, &color))
     {
         PyErr_Clear ();
         if (!PyArg_ParseTuple (args, "OiiiiO:line", &surface, &x1, &_y1,

src/sdlimage/imagemod.c

     if (!PyArg_ParseTuple (args, "|l:init", &flags))
         return NULL;
     retval = IMG_Init (flags);
-    return PyInt_FromLong (flags);
+    return PyInt_FromLong (retval);
 }
 
 static PyObject*