* DEALINGS IN THE SOFTWARE.
*/
-#include <stdio.h>
#include "egldriver.h"
#include "eglcurrent.h"
#include "egllog.h"
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_format.h"
+#include "util/u_string.h"
#include "egl_g3d.h"
#include "egl_g3d_api.h"
gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL);
if (!num_connectors) {
if (native_connectors)
- free(native_connectors);
+ FREE(native_connectors);
return;
}
gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes);
if (!num_modes) {
if (native_modes)
- free(native_modes);
+ FREE(native_modes);
continue;
}
gscr = CALLOC_STRUCT(egl_g3d_screen);
if (!gscr) {
- free(native_modes);
+ FREE(native_modes);
continue;
}
_eglAddScreen(dpy, &gscr->base);
}
- free(native_connectors);
+ FREE(native_connectors);
}
#endif /* EGL_MESA_screen_surface */
native_configs = gdpy->native->get_configs(gdpy->native, &num_configs);
if (!num_configs) {
if (native_configs)
- free(native_configs);
+ FREE(native_configs);
return id;
}
_eglInitConfig(&gconf->base, dpy, id);
if (!egl_g3d_init_config(drv, dpy, &gconf->base,
native_configs[i], depth_stencil_formats[j])) {
- free(gconf);
+ FREE(gconf);
break;
}
}
}
- free(native_configs);
+ FREE(native_configs);
return id;
}
if (dpy->Screens) {
for (i = 0; i < dpy->NumScreens; i++) {
struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]);
- free(gscr->native_modes);
- free(gscr);
+ FREE(gscr->native_modes);
+ FREE(gscr);
}
- free(dpy->Screens);
+ FREE(dpy->Screens);
}
if (gdpy->smapi)
if (gdpy->native)
gdpy->native->destroy(gdpy->native);
- free(gdpy);
+ FREE(gdpy);
dpy->DriverData = NULL;
return EGL_TRUE;
}
egl_g3d_destroy_probe(drv, NULL);
- free(gdrv);
+ FREE(gdrv);
}
_EGLDriver *
static char driver_name[64];
struct egl_g3d_driver *gdrv;
- snprintf(driver_name, sizeof(driver_name),
+ util_snprintf(driver_name, sizeof(driver_name),
"Gallium/%s", native_get_name());
gdrv = CALLOC_STRUCT(egl_g3d_driver);
}
if (!_eglInitContext(&gctx->base, dpy, conf, attribs)) {
- free(gctx);
+ FREE(gctx);
return NULL;
}
gctx->stapi = egl_g3d_choose_st(drv, &gctx->base);
if (!gctx->stapi) {
- free(gctx);
+ FREE(gctx);
return NULL;
}
gctx->stctxi = gctx->stapi->create_context(gctx->stapi, gdpy->smapi,
&gconf->stvis, (gshare) ? gshare->stctxi : NULL);
if (!gctx->stctxi) {
- free(gctx);
+ FREE(gctx);
return NULL;
}
gctx->stctxi->destroy(gctx->stctxi);
- free(gctx);
+ FREE(gctx);
}
static EGLBoolean
}
if (!_eglInitSurface(&gsurf->base, dpy, arg->type, conf, attribs)) {
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
}
if (!nsurf) {
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
/* initialize the geometry */
if (!nsurf->validate(nsurf, 0x0, &gsurf->sequence_number, NULL,
&gsurf->base.Width, &gsurf->base.Height)) {
nsurf->destroy(nsurf);
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
if (!gsurf->stfbi) {
nsurf->destroy(nsurf);
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
}
if (!_eglInitSurface(&gsurf->base, dpy, EGL_PBUFFER_BIT, conf, attribs)) {
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
if (!gsurf->stfbi) {
- free(gsurf);
+ FREE(gsurf);
return NULL;
}
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
if (gsurf->native)
gsurf->native->destroy(gsurf->native);
- free(gsurf);
+ FREE(gsurf);
}
static EGLBoolean
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
}
if (!_eglInitImage(&gimg->base, dpy, attribs)) {
- free(gimg);
+ FREE(gimg);
return NULL;
}
}
if (!ptex) {
- free(gimg);
+ FREE(gimg);
return NULL;
}
if (level > ptex->last_level) {
_eglError(EGL_BAD_MATCH, "eglCreateEGLImageKHR");
pipe_resource_reference(&gimg->texture, NULL);
- free(gimg);
+ FREE(gimg);
return NULL;
}
if (zslice > ptex->depth0) {
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
pipe_resource_reference(&gimg->texture, NULL);
- free(gimg);
+ FREE(gimg);
return NULL;
}
struct egl_g3d_image *gimg = egl_g3d_image(img);
pipe_resource_reference(&gimg->texture, NULL);
- free(gimg);
+ FREE(gimg);
return EGL_TRUE;
}
egl_g3d_destroy_st_manager(struct st_manager *smapi)
{
struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi);
- free(gsmapi);
+ FREE(gsmapi);
}
static boolean
void
egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
{
- free(stfbi);
+ FREE(stfbi);
}
/**
* Get the supported configs. The configs are owned by the display, but
- * the returned array should be free()ed.
+ * the returned array should be FREE()ed.
*/
const struct native_config **(*get_configs)(struct native_display *ndpy,
int *num_configs);
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdio.h>
-#include <string.h>
-
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
+#include "util/u_string.h"
#include "egllog.h"
#include "native_kms.h"
pipe_resource_reference(&ptex, NULL);
}
- free(ksurf);
+ FREE(ksurf);
}
static struct kms_surface *
/* delete old data */
if (kconn->connector) {
drmModeFreeConnector(kconn->connector);
- free(kconn->kms_modes);
+ FREE(kconn->kms_modes);
kconn->connector = NULL;
kconn->kms_modes = NULL;
return NULL;
count = kconn->connector->count_modes;
- kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes));
+ kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
if (!kconn->kms_modes) {
drmModeFreeConnector(kconn->connector);
kconn->connector = NULL;
kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
}
- nmodes_return = malloc(count * sizeof(*nmodes_return));
+ nmodes_return = MALLOC(count * sizeof(*nmodes_return));
if (nmodes_return) {
for (i = 0; i < count; i++)
nmodes_return[i] = &kconn->kms_modes[i].base;
if (!kdpy->connectors) {
kdpy->connectors =
- calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
+ CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
if (!kdpy->connectors)
return NULL;
kdpy->num_connectors = kdpy->resources->count_connectors;
}
- connectors = malloc(kdpy->num_connectors * sizeof(*connectors));
+ connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
if (connectors) {
for (i = 0; i < kdpy->num_connectors; i++)
connectors[i] = &kdpy->connectors[i].base;
struct native_config *nconf;
enum pipe_format format;
- kdpy->config = calloc(1, sizeof(*kdpy->config));
+ kdpy->config = CALLOC(1, sizeof(*kdpy->config));
if (!kdpy->config)
return NULL;
format = PIPE_FORMAT_NONE;
}
if (format == PIPE_FORMAT_NONE) {
- free(kdpy->config);
+ FREE(kdpy->config);
kdpy->config = NULL;
return NULL;
}
nconf->scanout_bit = TRUE;
}
- configs = malloc(sizeof(*configs));
+ configs = MALLOC(sizeof(*configs));
if (configs) {
configs[0] = &kdpy->config->base;
if (num_configs)
int i;
if (kdpy->config)
- free(kdpy->config);
+ FREE(kdpy->config);
if (kdpy->connectors) {
for (i = 0; i < kdpy->num_connectors; i++) {
struct kms_connector *kconn = &kdpy->connectors[i];
if (kconn->connector) {
drmModeFreeConnector(kconn->connector);
- free(kconn->kms_modes);
+ FREE(kconn->kms_modes);
}
}
- free(kdpy->connectors);
+ FREE(kdpy->connectors);
}
if (kdpy->shown_surfaces)
- free(kdpy->shown_surfaces);
+ FREE(kdpy->shown_surfaces);
if (kdpy->saved_crtcs) {
for (i = 0; i < kdpy->resources->count_crtcs; i++) {
drmModeFreeCrtc(kcrtc->crtc);
}
}
- free(kdpy->saved_crtcs);
+ FREE(kdpy->saved_crtcs);
}
if (kdpy->resources)
if (kdpy->api)
kdpy->api->destroy(kdpy->api);
- free(kdpy);
+ FREE(kdpy);
}
/**
kdpy->api = api;
if (!kdpy->api) {
_eglLog(_EGL_WARNING, "failed to create DRM API");
- free(kdpy);
+ FREE(kdpy);
return NULL;
}
}
kdpy->saved_crtcs =
- calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
if (!kdpy->saved_crtcs) {
kms_display_destroy(&kdpy->base);
return NULL;
}
kdpy->shown_surfaces =
- calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
if (!kdpy->shown_surfaces) {
kms_display_destroy(&kdpy->base);
return NULL;
drm_api = drm_api_create();
if (drm_api)
- snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name);
+ util_snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name);
else
- snprintf(kms_name, sizeof(kms_name), "KMS");
+ util_snprintf(kms_name, sizeof(kms_name), "KMS");
return kms_name;
}
/* we should be able to do better... */
if (xbufs && dri2surf->last_num_xbufs == num_outs &&
memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) {
- free(xbufs);
+ FREE(xbufs);
dri2surf->client_stamp = dri2surf->server_stamp;
return;
}
dri2surf->client_stamp = dri2surf->server_stamp;
if (dri2surf->last_xbufs)
- free(dri2surf->last_xbufs);
+ FREE(dri2surf->last_xbufs);
dri2surf->last_xbufs = xbufs;
dri2surf->last_num_xbufs = num_outs;
}
int i;
if (dri2surf->last_xbufs)
- free(dri2surf->last_xbufs);
+ FREE(dri2surf->last_xbufs);
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
struct pipe_resource *ptex = dri2surf->textures[i];
util_hash_table_remove(dri2surf->dri2dpy->surfaces,
(void *) dri2surf->drawable);
}
- free(dri2surf);
+ FREE(dri2surf);
}
static struct dri2_surface *
return NULL;
num_modes = x11_context_modes_count(modes);
- dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs));
+ dri2dpy->configs = CALLOC(num_modes, sizeof(*dri2dpy->configs));
if (!dri2dpy->configs)
return NULL;
dri2dpy->num_configs = count;
}
- configs = malloc(dri2dpy->num_configs * sizeof(*configs));
+ configs = MALLOC(dri2dpy->num_configs * sizeof(*configs));
if (configs) {
for (i = 0; i < dri2dpy->num_configs; i++)
configs[i] = (const struct native_config *) &dri2dpy->configs[i];
struct dri2_display *dri2dpy = dri2_display(ndpy);
if (dri2dpy->configs)
- free(dri2dpy->configs);
+ FREE(dri2dpy->configs);
if (dri2dpy->base.screen)
dri2dpy->base.screen->destroy(dri2dpy->base.screen);
XCloseDisplay(dri2dpy->dpy);
if (dri2dpy->api && dri2dpy->api->destroy)
dri2dpy->api->destroy(dri2dpy->api);
- free(dri2dpy);
+ FREE(dri2dpy);
}
static void
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdio.h>
#include <string.h>
#include "util/u_debug.h"
#include "util/u_memory.h"
+#include "util/u_string.h"
#include "state_tracker/drm_api.h"
#include "egllog.h"
x11_probe_destroy(struct native_probe *nprobe)
{
if (nprobe->data)
- free(nprobe->data);
- free(nprobe);
+ FREE(nprobe->data);
+ FREE(nprobe);
}
struct native_probe *
if (!xdpy) {
xdpy = XOpenDisplay(NULL);
if (!xdpy) {
- free(nprobe);
+ FREE(nprobe);
return NULL;
}
}
api = drm_api_create();
if (api)
- snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name);
+ util_snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name);
else
- snprintf(x11_name, sizeof(x11_name), "X11");
+ util_snprintf(x11_name, sizeof(x11_name), "X11");
return x11_name;
}
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <sys/ipc.h>
-#include <sys/types.h>
-#include <sys/shm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "util/u_memory.h"
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
ximage_surface_free_buffer(&xsurf->base, i);
- free(xsurf);
+ FREE(xsurf);
}
static struct ximage_surface *
* Create two configs for each visual.
* One with depth/stencil buffer; one without
*/
- xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs));
+ xdpy->configs = CALLOC(num_visuals * 2, sizeof(*xdpy->configs));
if (!xdpy->configs)
return NULL;
xdpy->num_configs = count;
}
- configs = malloc(xdpy->num_configs * sizeof(*configs));
+ configs = MALLOC(xdpy->num_configs * sizeof(*configs));
if (configs) {
for (i = 0; i < xdpy->num_configs; i++)
configs[i] = (const struct native_config *) &xdpy->configs[i];
struct ximage_display *xdpy = ximage_display(ndpy);
if (xdpy->configs)
- free(xdpy->configs);
+ FREE(xdpy->configs);
xdpy->base.screen->destroy(xdpy->base.screen);
x11_screen_destroy(xdpy->xscr);
if (xdpy->own_dpy)
XCloseDisplay(xdpy->dpy);
- free(xdpy);
+ FREE(xdpy);
}
if (!xdpy->dpy) {
xdpy->dpy = XOpenDisplay(NULL);
if (!xdpy->dpy) {
- free(xdpy);
+ FREE(xdpy);
return NULL;
}
xdpy->own_dpy = TRUE;
xdpy->xscr_number = DefaultScreen(xdpy->dpy);
xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
if (!xdpy->xscr) {
- free(xdpy);
+ FREE(xdpy);
return NULL;
}
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <xf86drm.h>
#include <X11/Xlibint.h>
#include <X11/extensions/XShm.h>
+
#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "util/u_format.h"
-#include "xf86drm.h"
#include "egllog.h"
#include "x11_screen.h"
if (xscr->visuals)
XFree(xscr->visuals);
- free(xscr);
+ FREE(xscr);
}
static boolean
next = &base;
for (i = 0; i < count; i++) {
- *next = (__GLcontextModes *) calloc(1, size);
+ *next = (__GLcontextModes *) CALLOC(1, size);
if (*next == NULL) {
x11_context_modes_destroy(base);
base = NULL;
{
while (modes != NULL) {
__GLcontextModes *next = modes->next;
- free(modes);
+ FREE(modes);
modes = next;
}
}