Esempio n. 1
0
static int _themeParseFontEntry(const char *json, jsmntok_t *tokens, const char *name, void *context) {
    flubGuiTheme_t *theme = (flubGuiTheme_t *)context;
    _jsonFontEntry_t entry;
    flubGuiThemeFont_t *font;

    memset(&entry, 0, sizeof(_jsonFontEntry_t));
    if(!jsonParseToStruct(json, tokens, _themeFontParseMap, "Theme font entry", &entry, _jsonFontCleanup)) {
        return 0;
    }
    font = util_calloc(sizeof(flubGuiThemeFont_t), 0, NULL);
    font->type = eFlubGuiThemeFont;
    font->id = entry.id;
    if(entry.filename != NULL) {
        if(!flubFontLoad(entry.filename)) {
            _jsonFontCleanup(&entry);
            util_free(font);
            return 0;
        }
    }
    if((font->font = fontGet(entry.font, entry.size, 0)) == NULL) {
        _jsonFontCleanup(&entry);
        util_free(font);
        return 0;
    }
    critbitInsert(&theme->fonts, name, font, NULL);
    _flubGuiThemeIndexAdd(theme, entry.id, font);
    debugf(DBG_GUI, DBG_GUI_DTL_THEME, "Found font \"%s\" as %d, file [%s], %s size %d", name, entry.id,
          entry.filename, entry.font, entry.size);
    _jsonFontCleanup(&entry);
    return 1;
}
Esempio n. 2
0
File: go.c Progetto: AlbertLkn/dmd
void go_term()
{
    vec_free(defkill);
    vec_free(starkill);
    vec_free(vptrkill);
    util_free(expnod);
    util_free(expblk);
    util_free(defnod);
}
Esempio n. 3
0
static void _jsonFontCleanup(void *data) {
    _jsonFontEntry_t *entry = (_jsonFontEntry_t *)data;

    if(entry->filename != NULL) {
        util_free(entry->filename);
        entry->filename;
    }
    if(entry->font != NULL) {
        util_free(entry->font);
        entry->font = NULL;
    }
}
Esempio n. 4
0
void go_term()
{
    vec_free(defkill);
    vec_free(starkill);
    vec_free(vptrkill);
#if TX86
    util_free(expnod);
    util_free(expblk);
    util_free(defnod);
#else
    MEM_BEF_FREE(expnod);
    MEM_BEF_FREE(expblk);
    MEM_BEF_FREE(defnod);
#endif
}
Esempio n. 5
0
void env_destroy_scope(env_t **env)
{
  node_t *cur;

  cur = (*env)->head->next;
  st_destroy(&(*env)->head->st);
  util_free((*env)->head);

  if (cur) {
    (*env)->head = cur;
  } else {
    util_free(*env);
    *env = NULL;
  }
}
Esempio n. 6
0
File: proj.c Progetto: juddy/edcde
/*
 * Enable project window actions
 */
static void
enable_proj_actions(
    Widget widget
)
{
    if (proj_transtbl == NULL)
    {
	String	   translations;
        int        len;

	len = strlen(base_translations) + 1;

	if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
            len += strlen(btn2_adjust_translations);

        translations = (String)util_malloc(len*sizeof(char));
        if (translations == NULL)
            return; /* yikes */

	strcpy(translations, base_translations);
        if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */ 
	    strcat(translations, btn2_adjust_translations);

	proj_transtbl = XtParseTranslationTable(translations);

	util_free(translations);
    }

    /* enable build mode behavior */
    XtVaSetValues(widget, 
		XtNtranslations, proj_transtbl,
        	NULL);
}
Esempio n. 7
0
static int _themeParseTextureEntry(const char *json, jsmntok_t *tokens, const char *name, void *context) {
    flubGuiTheme_t *theme = (flubGuiTheme_t *)context;
    _jsonTextureEntry_t entry;
    flubGuiThemeTexture_t *texture;
    int red = 0;
    int green = 0;
    int blue = 0;

    memset(&entry, 0, sizeof(_jsonTextureEntry_t));
    if(!jsonParseToStruct(json, tokens, _themeTextureParseMap, "Theme texture entry", &entry, _jsonTextureCleanup)) {
        return 0;
    }
    texture = util_calloc(sizeof(flubGuiThemeTexture_t), 0, NULL);
    texture->type = eFlubGuiThemeTexture;
    texture->id = entry.id;
    if(entry.colorkey != NULL) {
        parseColor(entry.colorkey, &red, &green, &blue, NULL);
    }
    if((texture->texture = texmgrLoad(entry.filename, NULL, entry.minfilter,
                                      entry.magfilter,
                                      ((entry.colorkey != NULL) ? 1 : 0),
                                      red, green, blue)) == NULL) {
        _jsonTextureCleanup(&entry);
        util_free(texture);
        return 0;
    }
    critbitInsert(&theme->textures, name, texture, NULL);
    _flubGuiThemeIndexAdd(theme, entry.id, texture);
    debugf(DBG_GUI, DBG_GUI_DTL_THEME, "Found texture \"%s\" as %d, file [%s], %s %s %s", name, entry.id,
          entry.filename, texmgrGLMinFilterStr(entry.minfilter),
          texmgrGLMagFilterStr(entry.magfilter), ((entry.colorkey == NULL) ? "No colorkey" : entry.colorkey));
    _jsonTextureCleanup(&entry);
    return 1;
}
Esempio n. 8
0
void widgetDestroy(widget_t *widget) {
    widget_t *walk, *last;

    if(widget == NULL) {
        return;
    }

    widgetThemeRelease(widget);

    _widgetOrphan(widget);

    while(widget->child != NULL) {
        widgetDestroy(widget->child);
    }

    if(widget->next != NULL) {
        widgetDestroy(widget->next);
    }

    if((widget->handlers != NULL) && (widget->handlers->destroy != NULL)) {
        widget->handlers->destroy(widget);
    }

    util_free(widget);
}
Esempio n. 9
0
/*
 * Move the object to the location of the last drag rect
 */
int
abobj_move(
    ABObj     obj, 
    XEvent    *event
)
{
    short	x_delta = 0;
    short	y_delta = 0;

    if (!first_move)
    {
        first_move = True;

	/* erase last box */
        x_box_r(parent, &move_rect);

	x_delta = move_rect.x - orig_rect.x;
	y_delta = move_rect.y - orig_rect.y;

	/*
	 * Before the move is performed, record undo information
	 */
	(void)abobj_set_undo(sel.list, sel.count, undo_move, AB_UNDO_MOVE);

	abobj_nudge_selected(sel.list, sel.count, x_delta, y_delta, True);

	util_free(sel.list);
        return OK;
    }
    return ERROR;

}
Esempio n. 10
0
int aio_socket_process(int timeout)
{
	DWORD bytes;
	ULONG_PTR completionKey;
	OVERLAPPED *pOverlapped;
	struct aio_context *ctx;
	struct aio_context_action *aio;

	if(GetQueuedCompletionStatus(s_iocp, &bytes, &completionKey, &pOverlapped, timeout))
	{
		assert(completionKey && pOverlapped);

		// action
		ctx = (struct aio_context*)completionKey;
		aio = (struct aio_context_action*)pOverlapped;

//		if(0 == iocp_check_closed(aio))
			aio->action(ctx, aio, 0, bytes);
		util_free(aio);
	}
	else
	{
		DWORD err = GetLastError();
		if(NULL == pOverlapped)
		{
			if(WAIT_TIMEOUT == err)
			{
				return 0; // timeout
			}
			else
			{
				assert(0); // exception
			}
		}
		else
		{
			// io failed
			assert(completionKey);
			ctx = (struct aio_context*)completionKey;
			aio = (struct aio_context_action*)pOverlapped;
//			if(0 == iocp_check_closed(aio))
				aio->action(ctx, aio, err, bytes);
			util_free(aio);
		}
	}
	return 1;
}
Esempio n. 11
0
static void _jsonTextureCleanup(void *data) {
    _jsonTextureEntry_t *entry = (_jsonTextureEntry_t *)data;

    if(entry->filename != NULL) {
        util_free(entry->filename);
        entry->filename = NULL;
    }
}
Esempio n. 12
0
static void _jsonColorCleanup(void *data) {
    _jsonColorEntry_t *entry = (_jsonColorEntry_t *)data;

    if(entry->color != NULL) {
        util_free(entry->color);
        entry->color = NULL;
    }
}
Esempio n. 13
0
STRING
abmfP_get_action_name(ABObj action)
{
    static char         name[256];
    STRING		parent_name = (STRING) NULL;
    ABObj               from = NULL, parent = NULL;
    STRING		tmpName = NULL;
    *name = 0;

    from = obj_get_from(action);
    if (action->info.action.auto_named && (from != NULL))
    {
        /* If the source object is the project,
         * then this is an "Application" connection.
	 * This probably won't happen because right
	 * now "Application" connections can only be
	 * of type AB_FUNC_USER_DEF (which means auto-
	 * named is FALSE).
         */
        if (obj_is_project(from))
	{
	    parent = obj_get_project(action);
	    parent_name = (STRING) util_malloc(
				strlen(obj_get_name(parent)) 
				+ APP_PREFIX_LEN + 1);
	    strcpy(parent_name, obj_get_name(parent));
	    strcat(parent_name, APP_PREFIX);
	}
	else
	{
            parent = obj_get_module(from);
            parent_name = obj_get_name(parent);
	}

        if (!util_strempty(parent_name) &&
            !util_strempty(obj_get_name(from)))
	{
	    sprintf(name, "%s_%s%s",
		    parent_name,
		    obj_get_name(from),
		    obj_get_func_name_suffix(action));
	}

        if (obj_is_project(from))
        {
	    util_free(parent_name);
	}
    }
    else
    {
	if ((tmpName = obj_get_func_name(action)) != NULL)
	{
	    sprintf(name, "%s", tmpName);
	}
    }

    return (name[0] == 0 ? NULL : name);
}
Esempio n. 14
0
void fx_resample_free(void* handle)
{
    if (!handle)
        return;
    struct fx_resampler* r = handle;
    for (int ch = 0; ch < r->channels; ch++)
        src_delete(r->state[ch]);
    util_free(r);
}
Esempio n. 15
0
static inline int aio_socket_result(struct aio_context_action *aio, int flag)
{
	DWORD ret = WSAGetLastError();
	if (WSA_IO_PENDING != ret)
	{
		assert(0 != (flag & InterlockedAnd(&aio->context->flags, ~flag)));
		util_free(aio);
		return ret;
	}
	return 0;
}
Esempio n. 16
0
/*
 * Here, we (finally), actually free the memory associated with an object
 */
int
objP_free_mem_impl(ABObj *objPtr)
{
#define obj (*objPtr)

    obj_destruct(obj);
    util_free(obj);
    obj= NULL;

    return 0;
#undef obj
}
Esempio n. 17
0
File: proj.c Progetto: juddy/edcde
void
proj_open_proj_okCB(
    Widget      widget,
    XtPointer   client_data,
    XmSelectionBoxCallbackStruct *call_data
)
{
    STRING      	proj_filename = (STRING) NULL;
    XmString		xm_buf = (XmString) NULL;
    DtbObjectHelpData	help_data = NULL;

    proj_filename = (STRING)objxm_xmstr_to_str(call_data->value);

    /* If the file chooser selection text field is empty, return */
    if ( util_strempty(proj_filename) )
    {
	dtb_proj_no_name_msg_initialize(&dtb_proj_no_name_msg);
	(void)dtb_show_modal_message(widget,
                        &dtb_proj_no_name_msg, NULL, NULL, NULL);
    }
    else if (!util_file_exists(proj_filename))
    {
        sprintf(Buf, catgets(Dtb_project_catd, 100, 8,
		"The file %s does not exist."), proj_filename);
	util_printf_err(Buf);
    }
    else if (!util_file_is_regular_file(proj_filename))
    {
	sprintf(Buf, catgets(Dtb_project_catd, 100, 69,
                "Cannot open %s.\n%s is not a regular file."),
		proj_filename, proj_filename);
        xm_buf = XmStringCreateLocalized(Buf);
        dtb_proj_error_msg_initialize(&dtb_proj_error_msg);

	help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
	help_data->help_text = catgets(Dtb_project_catd, 100, 89,
	    "The file you specified is a directory or\nanother special file.");
	help_data->help_volume = "";
	help_data->help_locationID = "";

        (void)dtb_show_modal_message(widget,
                        &dtb_proj_error_msg, xm_buf, help_data, NULL);

	util_free(help_data);
        XmStringFree(xm_buf);
    }
    else
    {   
        XtUnmanageChild(widget);	/* pop down the chooser */
	ab_check_and_open_bip(proj_filename); 
    }    
}
Esempio n. 18
0
LIBSBML_EXTERN
void
util_freeArray (void ** objects, int length)
{
  int i;
  if (objects == NULL) return;
  for (i = 0; i < length; i++)    
  {
    util_free(objects[i]);
  }
  free(objects);

}
Esempio n. 19
0
File: cgcs.c Progetto: Abscissa/dmd
void cgcs_term()
{
    vec_free(csvec);
    csvec = NULL;
#ifdef DEBUG
    debugw && dbg_printf("freeing hcstab\n");
#endif
#if TX86
    util_free(hcstab);
#else
    MEM_PARF_FREE(hcstab);
#endif
    hcstab = NULL;
    hcsmax = 0;
}
Esempio n. 20
0
int aio_socket_accept(aio_socket_t socket, aio_onaccept proc, void* param)
{
	struct aio_context *ctx = (struct aio_context*)socket;
	struct aio_context_action *aio;
	DWORD dwBytes = 0;

	WSAPROTOCOL_INFOW pi;
	int len = sizeof(pi);
	if (0 != getsockopt(ctx->socket, SOL_SOCKET, SO_PROTOCOL_INFO, (char*)&pi, &len))
		return WSAGetLastError();

	aio = util_alloc(ctx);
	aio->action = iocp_accept;
	aio->accept.proc = proc;
	aio->accept.param = param;
	aio->accept.socket = WSASocket(pi.iAddressFamily, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
	if(INVALID_SOCKET == aio->accept.socket)
	{
		closesocket(aio->accept.socket);
		util_free(aio);
		return WSAGetLastError();
	}

	dwBytes = sizeof(aio->accept.buffer) / 2;
	if(!AcceptEx(ctx->socket, aio->accept.socket, aio->accept.buffer, 0, dwBytes, dwBytes, &dwBytes, &aio->overlapped))
	{
		DWORD ret = WSAGetLastError();
		if(ERROR_IO_PENDING != ret)
		{
			closesocket(aio->accept.socket);
			util_free(aio);
			return ret;
		}
	}
	return 0;
}
Esempio n. 21
0
static void _flubGuiThemeFree(flubGuiTheme_t *theme) {
    flubGuiTheme_t *walk;

    if(_guiThemeCtx.themes == theme) {
        _guiThemeCtx.themes = theme->next;
    } else if(_guiThemeCtx.themes != NULL) {
        for(walk = _guiThemeCtx.themes; ((walk->next != NULL) && (walk->next != theme)); walk = walk->next);
        if(walk->next == theme) {
            walk->next = theme->next;
        }
    }

    // TODO

    util_free(theme);
}
Esempio n. 22
0
compState_t *tsCompStateClear(compState_t *state) {
    compState_t *parent, *walk, *next;

    if(state->parent != NULL) {
        parent = state->parent;
        state = parent;
        if(parent->next != NULL) {
            for(walk = parent->next; walk != NULL; walk = next) {
                next = walk->next;
                util_free(walk);
            }
        }
    }
    tsCompStateInit(state, state->texture, state->type);
    return state;
}
Esempio n. 23
0
END_TEST

START_TEST (test_util_accessWithNULL)
{
  fail_unless ( util_bsearchStringsI(NULL, NULL, 0, 0) == 1 );
  fail_unless ( util_file_exists(NULL) == 0 );

  util_free(NULL);

  fail_unless ( util_trim(NULL) == NULL );
  fail_unless ( util_trim_in_place(NULL) == NULL );

  fail_unless ( safe_fopen(NULL, NULL) == NULL );
  fail_unless ( safe_strcat(NULL, NULL) == NULL );
  fail_unless ( safe_strdup(NULL) == NULL );

}
Esempio n. 24
0
void 
cgenP_reset_envCB(
    Widget widget,
    XtPointer clientData,
    XtPointer callData
)
{
    /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
    DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
    STRING                      var_name = NULL;
    STRING                      var_value = NULL;

    var_name = XmTextFieldGetString(env_dlg->name_textf);

    if (util_strempty(var_name))
        return;

    if (strlist_str_exists(user_env_vars, var_name))
    {
        /* the user has set this before - we need to deallocate
         * the string we allocated
         */
        var_value = (STRING) strlist_get_str_data(user_env_vars, var_name);
        util_free(var_value);
        strlist_remove_str(user_env_vars, var_name);
    }
    var_value = getenv(var_name);

    if (var_value == NULL)
    {
	XmTextSetString(env_dlg->textpane, catgets(Dtb_project_catd, 100, 58, "*** Not Set ***"));
    }
    else
    {
	XmTextSetString(env_dlg->textpane, var_value);
    }

    /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
    
    /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
    /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
}
Esempio n. 25
0
void
ui_field_select_string(
    Widget	field,
    BOOL	assign_focus
)
{
    STRING	valuestr = NULL;

    valuestr = ui_field_get_string(field);

    if (XtIsSubclass(field, xmTextFieldWidgetClass))
    	XmTextFieldSetSelection(field, 0, strlen(valuestr), CurrentTime);
    else if (XtIsSubclass(field, xmTextWidgetClass))
	XmTextSetSelection(field, 0, strlen(valuestr), CurrentTime);

    if (assign_focus) 
        XmProcessTraversal(field, XmTRAVERSE_CURRENT);

    util_free(valuestr);
}
Esempio n. 26
0
int aio_socket_sendto_v(aio_socket_t socket, const struct sockaddr *addr, socklen_t addrlen, socket_bufvec_t* vec, int n, aio_onsend proc, void* param)
{
	struct aio_context *ctx = (struct aio_context*)socket;
	struct aio_context_action *aio;
	
	aio = util_alloc(ctx);
	aio->action = iocp_send;
	aio->send.proc = proc;
	aio->send.param = param;

	if(SOCKET_ERROR == WSASendTo(ctx->socket, vec, (DWORD)n, NULL, 0, addr, addrlen, &aio->overlapped, NULL))
	{
		DWORD ret = WSAGetLastError();
		if(WSA_IO_PENDING != ret)
		{
			util_free(aio);
			return ret;
		}
	}
	return 0;
}
Esempio n. 27
0
int aio_socket_connect(aio_socket_t socket, const struct sockaddr *addr, socklen_t addrlen, aio_onconnect proc, void* param)
{
	struct aio_context *ctx = (struct aio_context*)socket;
	struct aio_context_action *aio;

	aio = util_alloc(ctx);
	aio->action = iocp_connect;
	aio->connect.proc = proc;
	aio->connect.param = param;

	if(!ConnectEx(ctx->socket, addr, addrlen, NULL, 0, NULL, &aio->overlapped))
	{
		DWORD ret = WSAGetLastError();
		if(ERROR_IO_PENDING != ret)
		{
			util_free(aio);
			return ret;
		}
	}
	return 0;
}
Esempio n. 28
0
void 
cgenP_set_envCB(
    Widget widget,
    XtPointer clientData,
    XtPointer callData
)
{
    /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/

    DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
    STRING                      var_name = NULL;
    STRING                      var_value = NULL;
    STRING                      old_var_value = NULL;

    var_name = XmTextFieldGetString(env_dlg->name_textf);

    if (util_strempty(var_name))
        return;

    var_value = XmTextGetString(env_dlg->textpane);

    if (strlist_str_exists(user_env_vars, var_name))
    {
        /* the user has set this before - we need to deallocate
         * the string we allocated
         */
        old_var_value = (STRING) strlist_get_str_data(user_env_vars, var_name);
        util_free(old_var_value);
        strlist_remove_str(user_env_vars, var_name);
    }
    if (!util_strempty(var_value))
        strlist_add_str(user_env_vars, var_name, (void *)strdup(var_value));
    else
        strlist_add_str(user_env_vars, var_name, (void *)NULL);

    /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
    
    /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
    /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
}
Esempio n. 29
0
int aio_socket_send_v(aio_socket_t socket, socket_bufvec_t* vec, int n, aio_onsend proc, void* param)
{
	DWORD dwBytes = 0;
	struct aio_context *ctx = (struct aio_context*)socket;
	struct aio_context_action *aio;

	aio = util_alloc(ctx);
	aio->action = iocp_send;
	aio->send.proc = proc;
	aio->send.param = param;

	if(SOCKET_ERROR == WSASend(ctx->socket, vec, n, &dwBytes, 0, &aio->overlapped, NULL))
	{
		DWORD ret = WSAGetLastError();
		if(WSA_IO_PENDING != ret)
		{
			util_free(aio);
			return ret;
		}
	}
	return 0;
}
Esempio n. 30
0
int aio_socket_recvfrom_v(aio_socket_t socket, socket_bufvec_t* vec, int n, aio_onrecvfrom proc, void* param)
{
	DWORD flags = 0;
	DWORD dwBytes = 0;
	struct aio_context *ctx = (struct aio_context*)socket;
	struct aio_context_action *aio;

	aio = util_alloc(ctx);
	aio->action = iocp_recvfrom;
	aio->recvfrom.proc = proc;
	aio->recvfrom.param = param;
	aio->recvfrom.addrlen = sizeof(aio->recvfrom.addr);

	if(SOCKET_ERROR == WSARecvFrom(ctx->socket, vec, (DWORD)n, &dwBytes, &flags, (struct sockaddr *)&aio->recvfrom.addr, &aio->recvfrom.addrlen, &aio->overlapped, NULL))
	{
		DWORD ret = WSAGetLastError();
		if(WSA_IO_PENDING != ret)
		{
			util_free(aio);
			return ret;
		}
	}
	return 0;
}