static Boolean nav_sel_convert_cb( Widget w, Atom *selection, Atom *target, Atom *type_return, XtPointer *value_return, unsigned long *length_return, int *format_return) { NavMotif *nav; brow_tCtx browctx; char name[200]; int sts; BrowCtxFromWidget( w, (void **) &browctx); brow_GetCtxUserData( browctx, (void **) &nav); if (*target == XA_TARGETS(flow_Display(nav->brow_widget))) { Atom *targetP; Atom *std_targets; unsigned long std_length; XSelectionRequestEvent *req = XtGetSelectionRequest( w, *selection, (XtRequestId)NULL); XmuConvertStandardSelection( w, req->time, selection, target, type_return, (caddr_t *)&std_targets, &std_length, format_return); *value_return = XtMalloc( sizeof(Atom) * (std_length + 2)); targetP = *(Atom **) value_return; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(flow_Display(nav->brow_widget)); *length_return = std_length + (targetP - (*(Atom **) value_return)); bcopy((char *)std_targets, (char *)targetP, sizeof(Atom) * std_length); XtFree( (char *)std_targets); *type_return = XA_ATOM; *format_return = 32; return True; } if (*target == XA_STRING) { if ( !nav->get_plant_select_cb) return FALSE; sts = nav->get_plant_select_cb( nav->parent_ctx, name, sizeof(name)); if ( EVEN(sts)) return FALSE; *value_return = XtNewString(name); *length_return = strlen(name) + 1; *type_return = XA_STRING; *format_return = 8; return TRUE; } return FALSE; }
Widget SoXtMaterialList::buildWidget(// protected Widget parent) { // we're building pulldown menu automatically... Widget root = XtVaCreateManagedWidget(this->getClassName(), xmFormWidgetClass, parent, NULL); Widget menubar = XtVaCreateManagedWidget("menubar", xmRowColumnWidgetClass, root, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNrowColumnType, XmMENU_BAR, NULL); Widget palettemenu = this->buildPulldownMenu(menubar); SoXtMaterialDirectory * dir = common->getMaterialDirectory(); int group, materials; XmStringTable list; if (dir->numGroups > 0) { group = dir->current; materials = dir->groups[group]->numMaterials; list = (XmStringTable) XtMalloc(sizeof(XmString) * materials); for (int i = 0; i < materials; i++) list[i] = SoXt::encodeString(dir->groups[group]->materials[i]->name); } else { materials = 0; list = NULL; } Arg argv[10]; int argc = 0; XtSetArg(argv[argc], XmNleftAttachment, XmATTACH_FORM); argc++; XtSetArg(argv[argc], XmNtopAttachment, XmATTACH_WIDGET); argc++; XtSetArg(argv[argc], XmNtopWidget, menubar); argc++; XtSetArg(argv[argc], XmNrightAttachment, XmATTACH_FORM); argc++; XtSetArg(argv[argc], XmNbottomAttachment, XmATTACH_FORM); argc++; XtSetArg(argv[argc], XmNselectionPolicy, XmSINGLE_SELECT); argc++; XtSetArg(argv[argc], XmNscrollBarDisplayPolicy, XmSTATIC); argc++; XtSetArg(argv[argc], XmNitems, list); argc++; XtSetArg(argv[argc], XmNitemCount, materials); argc++; this->listwidget = XmCreateScrolledList(root, "materials", argv, argc); XtManageChild(this->listwidget); XtAddCallback(this->listwidget, XmNdefaultActionCallback, SoXtMaterialList::selection_cb, (void *) this); for (int i = 0; i < materials; i++) XmStringFree(list[i]); XtFree((char *) list); return root; } // buildWidget()
XmRepTypeId XmRepTypeRegister(String rep_type, String *value_names, unsigned char *values, unsigned char num_values) { int i, len; char *cp; XmRepTypeId id = XmRepTypeGetId(rep_type); XmRepTypeEntryRec ne; XtConvertArgRec Args[1]; if (id != XmREP_TYPE_INVALID) { return id; } if (number_of_types + 1 > max_number_of_types) { max_number_of_types = (max_number_of_types + 1) * 2; rep_types = (XmRepTypeList)XtRealloc((char *)rep_types, sizeof(XmRepTypeListRec) * max_number_of_types); } /* Find the total size of the lists and strings, and allocate it */ len = 0; for (i = 0; i < num_values; i++) len += strlen(value_names[i]); cp = XtMalloc(strlen(rep_type) + 1 + num_values * (values ? sizeof(String) + 2 : sizeof(String) + 1) + len); /* Copy the data into the new record */ ne.rep_type_name = rep_type; ne.value_names = value_names; ne.values = values; ne.num_values = num_values; ne.reverse_installed = False; ne.rep_type_id = number_of_types; __XmRepTypeCopyRecord(rep_types + number_of_types, &ne, (String *)cp, (char *)((String *)cp + num_values)); /* now install the forward converter */ Args[0].address_mode = XtImmediate; Args[0].address_id = (XtPointer)(long)number_of_types; Args[0].size = sizeof(XmRepTypeId); XtSetTypeConverter(XmRString, rep_type, __XmCvtStringToRep, Args, 1, XtCacheNone, NULL); return number_of_types++; }
void fileExecCb(Widget w, XtPointer client_data, XtPointer call_data) { FileWindowRec *fw = (FileWindowRec *) client_data; ExecFileRec *data = (ExecFileRec *) XtMalloc(sizeof(ExecFileRec)); TextFieldRec argLine[2]; int item; XtVaGetValues(fw->form, XmNuserData, (XtPointer) &item, NULL); data->directory = XtNewString(fw->directory); data->action = (String) XtMalloc((sizeof(fw->files[item]->name) + 8) * sizeof(char)); strcpy(data->action, "exec ./"); strcat(data->action, fw->files[item]->name); data->shell = fw->shell; data->icon = icons[EXEC_BM]; argLine[0].label = "Arguments:"; *(argLine[0].value = &data->arguments) = NULL; argLine[1].label = NULL; textFieldDialog(fw->shell, argLine, fileExecProc, (XtPointer) data, data->icon.bm); }
/* * IconNew * * Allocate memory for a new icon structure and clear. */ IconInfo* IconNew() { IconInfo *iconPtr; iconPtr = (IconInfo*) XtMalloc(sizeof(IconInfo)); memset(iconPtr, 0x00, sizeof(IconInfo)); return iconPtr; }
static void SFunreadableDir (SFDir *dir) { char *cannotOpen = "<cannot open> "; dir->entries = (SFEntry *) XtMalloc (sizeof (SFEntry)); dir->entries[0].statDone = 1; SFstrdup (&dir->entries[0].real, cannotOpen); dir->entries[0].shown = dir->entries[0].real; dir->nEntries = 1; dir->nChars = strlen (cannotOpen); }
static XtPointer GetResourceValues( XrmDatabase data_base, char **name_list ) { ChangeDirData * change_dir_data; XmStringTable new_table; int i; /* Allocate and get the resources for change dir dialog data. */ change_dir_data = (ChangeDirData *) XtMalloc (sizeof (ChangeDirData)); _DtDialogGetResources (data_base, name_list, CHANGEDIRECTORY, (char *) change_dir_data, resources, changeDirClass->resource_count); change_dir_data->host_name = NULL; /* If the history list is Non-Null, realloc the pointer array */ /* one element larger and NULL out the new last element */ if (change_dir_data->list_count != 0) { new_table = (XmStringTable) XtMalloc (sizeof (XmStringTable) * (change_dir_data->list_count + 1)); for (i = 0; i < change_dir_data->list_count; i++) new_table[i] = change_dir_data->history_list[i]; new_table[change_dir_data->list_count] = NULL; /****************** THIS WILL BE A MEMORY HOLE WHEN MOTIF FIXES THE XMSTRINGTABLE CONVERTER. EITHER REALLOC THE RETURNED TABLE OR COPY AND FREE IT. ******************/ change_dir_data->history_list = new_table; } return ((XtPointer) change_dir_data); }
Boolean FillWidgetWithFile ( Widget widget, char filename[] ) /************************************************************************ * FillWidgetWithFile * * * * Boolean FillWidgetWithFile( widget, filename ) * * * * Input parameters: * * widget Widget * * filename[] char * * * * Output parameters: * * FillWidgetWithFile Boolean * ** * * Log: * * S. Jacobs/NCEP 3/04 Removed unprintable characters * ***********************************************************************/ { FILE *fp; struct stat file_info; char *buffer; long bytes_read; int ier; /*---------------------------------------------------------------------*/ if ( (fp = fopen(filename, "r")) == NULL ) return( False ); if ( stat(filename, &file_info ) != 0 ) { fclose(fp); return( False ); } buffer = (char *) XtMalloc( file_info.st_size + 5); if ( buffer == (char *) NULL) { fclose( fp ); return( False ); } bytes_read = (long) fread( buffer, 1, file_info.st_size, fp); fclose(fp); buffer[file_info.st_size-1] = '\0'; cst_unpr ( buffer, buffer, &ier ); if ( bytes_read < file_info.st_size) { XtFree( buffer ); return( False ); } XmTextSetString( widget, buffer ); XtFree( buffer ); return( True ); }
/* ** CreateListData(): routine to convert the ** poem into an array of compound strings */ XmStringTable CreateListData (int *count) { XmStringTable table = (XmStringTable) 0 ; int line = 0 ; int column = 0 ; int index = 0 ; XmString entry ; XmString row =NULL; XmString tmp =NULL; XmString tab; tab = XmStringComponentCreate (XmSTRING_COMPONENT_TAB, 0, NULL); while (poem[index] != (char *) 0) { /* create a compound string, using the rendition tag */ entry = XmStringGenerate ((XtPointer) poem[index], NULL, XmCHARSET_TEXT, rendition_data[column].tag) ; if (row != (XmString)NULL) { tmp = XmStringConcat (row, tab) ; XmStringFree (row) ; row = XmStringConcatAndFree (tmp, entry) ; } else { row = entry ; } ++column ; if (column == MAX_COLUMNS) { if (table == (XmStringTable) 0) { table = (XmStringTable) XtMalloc((unsigned) 1 * sizeof (XmString)) ; } else { table = (XmStringTable) XtRealloc((char *) table, (unsigned) (line + 1) * sizeof (XmString)) ; } table[line++] = row ; row = (XmString) 0 ; column = 0 ; } index++ ; } XmStringFree (tab) ; table[line] = (XmString) 0 ; *count = line ; return table ; }
static void entry_transfer(Widget dt, int which) { XmDropTransferList lst = &DT_DropTransferLists(dt)[which]; Widget dc = DT_DragContext(dt); Cardinal i; DEBUGOUT(_LtDebug(__FILE__, dt, "%s:entry_transfer(%d)", __FILE__, __LINE__)); DT_CurDropTransferList(dt) = which; DT_CurTargets(dt) = (Atom *)XtMalloc(lst->num_transfers * sizeof(Atom)); DT_CurClientData(dt) = (XtPointer *)XtMalloc(lst->num_transfers * sizeof(XtPointer)); for (i = 0; i < lst->num_transfers; i++) { DT_CurTargets(dt)[i] = lst->transfer_list[i].target; DT_CurClientData(dt)[i] = (XtPointer)dt; } DT_CurXfer(dt) = 0; if (DT_Incremental(dt)) { XtGetSelectionValuesIncremental(DC_CurrReceiverInfo(dc)->shell, DC_ICCHandle(dc), DT_CurTargets(dt), lst->num_transfers, select_callback, (XtPointer)DT_CurClientData(dt), DT_Timestamp(dt)); } else { XtGetSelectionValues(DC_CurrReceiverInfo(dc)->shell, DC_ICCHandle(dc), DT_CurTargets(dt), lst->num_transfers, select_callback, (XtPointer)DT_CurClientData(dt), DT_Timestamp(dt)); } }
/*----------------------------------------------------------------------* | SendInclude | *----------------------------------------------------------------------*/ void SendIncludeCommand(Window window, int commID, Boolean is_in_line) { Time time; XtPointer msg, save; CARD32 commandID = 0L; CARD32 in_line = 0L; CARD32 selection = 0L; CARD32 count = 1L; CARD32 windowBit = 1<<30; /* CARD32 iconBit = 1<<31;*/ char str[128]; int size=0; commandID += commID; selection += atoms.own_selection; if (is_in_line) { in_line = 1L; } time = GetTimestamp(dsp); /* * Fixup the window id receiving the client command. * Top 2 bits: * 10 - Icon only * 01 - Window only * 11 - Both Icon and Window * 00 - Reserved (Don't Use!) * * Bottom 30 bits: * 0x3fffffff - All windows and/or icons * 0x00000000 - Root window menu */ size += sizeof(CARD32); /* in-line*/ size += sizeof(CARD32); /* command id */ size += sizeof(CARD32); /* selection */ size += sizeof(CARD32); /* count */ size += sizeof(CARD32); /* window */ save = msg = (XtPointer) XtMalloc(size); window |= windowBit; msg = PackCARD32(msg, (CARD32)in_line); msg = PackCARD32(msg, (CARD32)commandID); msg = PackCARD32(msg, (CARD32)selection); msg = PackCARD32(msg, (CARD32)count); msg = PackCARD32(msg, (CARD32)window); PRINT("IncludeCommand #%d on window %x (%u).\n", commandID, window, window); SendMessage(INCLUDE, save, size, time); }
void MenuBar::removeCommands( Widget pulldown, CmdList *redundant_list ) { // if(isValidMenuPane(pulldown) == FALSE) // return; int i, j, num_children; WidgetList children; XtVaGetValues(pulldown, XmNnumChildren, &num_children, NULL); children = (WidgetList)XtMalloc(sizeof(Widget) * num_children); XtVaGetValues(pulldown, XmNchildren, &children, NULL); // Loop through widget list. Destroy those widgets that map to those // in the redundant list. for (i=0; i<num_children; i++) { Widget wid = (Widget) children[i]; if (XtIsSubclass(wid, xmSeparatorWidgetClass)) { XtUnmanageChild(wid); } else if (XtIsSubclass(wid, xmPushButtonWidgetClass)) { for (j=0; j<redundant_list->size(); j++) { XmString str=NULL; String label=NULL; XtVaGetValues(wid, XmNlabelString, &str, NULL); if (str == NULL) continue; label = NULL; label = (char *) _XmStringUngenerate( str, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); XmStringFree(str); if (label == NULL) continue; if (strcmp(label, (*redundant_list)[j]->getLabel()) == 0) { // The redundant item has been found. XtUnmanageChild(wid); } XtFree(label); } } } }
DEFINE_MODEL_PROTOTYPE MODEL_interface * initialize_model () { MODEL_interface * mi = NULL; /*----- first, see if the user wants help -----*/ if( AFNI_yesenv("AFNI_MODEL_HELP_CONVDIFFGAM") || AFNI_yesenv("AFNI_MODEL_HELP_ALL") ) model_help(); /*----- allocate memory space for model interface -----*/ mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface)); /*----- name of this model -----*/ strcpy (mi->label, "ConvDiffGam"); /*----- this is a signal model -----*/ mi->model_type = MODEL_SIGNAL_TYPE; /*----- number of parameters in the model -----*/ mi->params = 8; /*----- parameter labels -----*/ strcpy (mi->plabel[0], "A0"); strcpy (mi->plabel[1], "T0"); strcpy (mi->plabel[2], "E0"); strcpy (mi->plabel[3], "D0"); strcpy (mi->plabel[4], "A1"); strcpy (mi->plabel[5], "T1"); strcpy (mi->plabel[6], "E1"); strcpy (mi->plabel[7], "D1"); /*----- minimum and maximum parameter constraints -----*/ mi->min_constr[0] = 0.0; mi->max_constr[0] = 10.0; mi->min_constr[1] = 0.0; mi->max_constr[1] = 10.0; mi->min_constr[2] = 0.0; mi->max_constr[2] = 10.0; mi->min_constr[3] = 0.0; mi->max_constr[3] = 10.0; mi->min_constr[4] = 0.0; mi->max_constr[4] = 10.0; mi->min_constr[5] = 0.0; mi->max_constr[5] = 10.0; mi->min_constr[6] = 0.0; mi->max_constr[6] = 10.0; mi->min_constr[7] = 0.0; mi->max_constr[7] = 10.0; /*----- function which implements the model -----*/ mi->call_func = conv_model; return (mi); }
static void iconEditCb(Widget w, XtPointer client_data, XtPointer call_data) { AppSpecRec *awi = (AppSpecRec *) XtMalloc(sizeof(AppSpecRec)); awi->win.dticon = (DTIconRec *) client_data; awi->item = DTICON; dticons_blocked = True; if (awi->win.dticon->app.objType == APPLICATION) appEdit(awi); else usrObjEdit(awi); }
static void BreakPiece(AsciiSrcObject src, Piece *piece) { Piece *cnew = AllocNewPiece(src, piece); cnew->text = XtMalloc((unsigned)src->ascii_src.piece_size); memcpy(cnew->text, piece->text + HALF_PIECE, (unsigned)(src->ascii_src.piece_size - HALF_PIECE)); piece->used = HALF_PIECE; cnew->used = src->ascii_src.piece_size - HALF_PIECE; }
static void UnpackWinEntry(MessageData *data, Display *dpy, int screen_num, WSMWinEntry *win_entry) { int i; win_entry->num_windows = UnpackListNum(data); win_entry->windows = (Window *) XtMalloc(sizeof(Window) * win_entry->num_windows); for (i=0; i<win_entry->num_windows; i++) win_entry->windows[i] = UnpackWindow(data); win_entry->num_match_properties = UnpackListNum(data); win_entry->match_properties = (WindowProperty *) XtMalloc(sizeof(WindowProperty) * win_entry->num_match_properties); for (i=0; i<win_entry->num_match_properties; i++) win_entry->match_properties[i] = UnpackProperty(data); }
/* Initialize the colormap based on the visual info. * This routine maintains a cache of visual-infos to colormaps. If two * widgets share the same visual info, they share the same colormap. * This function is called by the callProc of the colormap resource entry. */ static void createColormap(GLwDrawingAreaWidget w, int offset, XrmValue *value) { static struct cmapCache { Visual *visual; Colormap cmap; int screen; } *cmapCache; static int cacheEntries=0; static int cacheMalloced=0; register int i; assert(w->glwDrawingArea.visualInfo); /* see if we can find it in the cache */ for (i=0; i<cacheEntries; i++) if (cmapCache[i].visual == w->glwDrawingArea.visualInfo->visual && cmapCache[i].screen == w->glwDrawingArea.visualInfo->screen) { value->addr = (XtPointer) (&cmapCache[i].cmap); return; } /* not in the cache, create a new entry */ if (cacheEntries >= cacheMalloced) { /* need to malloc a new one. Since we are likely to have only a * few colormaps, we allocate one the first time, and double * each subsequent time. */ if (cacheMalloced == 0) { cacheMalloced = 1; cmapCache = (struct cmapCache *)XtMalloc(sizeof(struct cmapCache)); } else { cacheMalloced <<= 1; cmapCache = (struct cmapCache *)XtRealloc((char *) cmapCache, sizeof(struct cmapCache)* cacheMalloced); } } cmapCache[cacheEntries].cmap = XCreateColormap (XtDisplay(w), RootWindow(XtDisplay(w), w->glwDrawingArea.visualInfo->screen), w->glwDrawingArea.visualInfo->visual, AllocNone); cmapCache[cacheEntries].visual = w->glwDrawingArea.visualInfo->visual; cmapCache[cacheEntries].screen = w->glwDrawingArea.visualInfo->screen; value->addr = (XtPointer) (&cmapCache[cacheEntries++].cmap); }
void AttachArea::DisplayAttachmentsInRow(unsigned int X) { int i; int managecount, unmanagecount; Attachment **list = getList(); WidgetList manageIconList, unmanageIconList; if (getIconCount()) { manageIconList = (WidgetList) XtMalloc(sizeof(Widget)*getIconCount()); unmanageIconList = (WidgetList) XtMalloc(sizeof(Widget)*getIconCount()); managecount = unmanagecount = 0; for(i=0;i<getIconCount();i++) { if(!list[i]->isDeleted()) { if(list[i]->getRow() == X) { if(!list[i]->isManaged()) { manageIconList[managecount] = list[i]->baseWidget(); managecount++; } } else { // if deleted if(list[i]->isManaged()) { unmanageIconList[unmanagecount] = list[i]->baseWidget(); unmanagecount++; } } } } XtUnmanageChildren(unmanageIconList, unmanagecount); XtManageChildren(manageIconList, managecount); XtFree((char *)manageIconList); XtFree((char *)unmanageIconList); } this->attachment_summary(_iconCount - _deleteCount, _deleteCount); }
List * ListInit(void) { List *l; l = (List *)XtMalloc(sizeof *l); if(!l) return l; l->next = l; l->prev = l; l->thing = NULL; return l; }
static XmDndAtomsTable create_default_atoms_table(Display *display) { XmDndAtomsTable tbl; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:create_default_atoms_table(%d)\n", __FILE__, __LINE__)); tbl = (XmDndAtomsTable) XtMalloc(sizeof(XmDndAtomsTableRec)); tbl->num_entries = 1; tbl->entries = (XmDndAtomsTableEntry) XtMalloc(sizeof(XmDndAtomsTableEntryRec)); tbl->entries->atom = XmInternAtom(display, _XA_MOTIF_ATOM_0, False); tbl->entries->time = CurrentTime; set_atoms_table(display, tbl); return tbl; }
char *qmonReadText(const char *filename, lList **alpp) { char *text = NULL; SGE_STRUCT_STAT statb; FILE *fp = NULL; DENTER(GUI_LAYER, "qmonReadText"); if (filename == NULL) { answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, "No filename specified"); DRETURN(NULL); } /* ** make sure the file is a regular text file and open it */ if (SGE_STAT(filename, &statb) == -1 || (statb.st_mode & S_IFMT) != S_IFREG || !(fp = fopen(filename, "r"))) { answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, MSG_FILE_OPENFAILED_S, filename); DRETURN(NULL); } /* ** put the contents of the file in the Text widget by allocating ** enough space for the entire file, reading the file into the ** allocated space, and using XmTextFieldSetString() to show the file. */ if ((text = XtMalloc((unsigned)(statb.st_size + 1))) == NULL) { answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, "%s", MSG_MEMORY_MALLOCFAILED); FCLOSE(fp); DRETURN(NULL); } if (!fread(text, sizeof (char), statb.st_size + 1, fp)) { answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, MSG_FILE_FREADFAILED_SS, filename, strerror(errno)); } text[statb.st_size] = 0; /* be sure to NULL-terminate */ FCLOSE(fp); DRETURN(text); FCLOSE_ERROR: XtFree(text); answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, MSG_FILE_NOCLOSE_SS, filename, strerror(errno)); DRETURN(NULL); }
/* * define our own putenv() if the system doesn't have one. * putenv(s): place s (a string of the form "NAME=value") in * the environment; replacing any existing NAME. s is placed in * environment, so if you change s, the environment changes (like * putenv on a sun). Binding removed if you putenv something else * called NAME. */ int putenv(char *s) { char *v; int varlen, idx; extern char **environ; char **newenv; static int virgin = 1; /* true while "environ" is a virgin */ v = strchr(s, '='); if(v == 0) return 0; /* punt if it's not of the right form */ varlen = (v + 1) - s; for (idx = 0; environ[idx] != 0; idx++) { if (strncmp(environ[idx], s, varlen) == 0) { if(v[1] != 0) { /* true if there's a value */ environ[idx] = s; return 0; } else { do { environ[idx] = environ[idx+1]; } while(environ[++idx] != 0); return 0; } } } /* add to environment (unless no value; then just return) */ if(v[1] == 0) return 0; if(virgin) { register i; newenv = (char **) XtMalloc((unsigned) ((idx + 2) * sizeof(char*))); if(newenv == 0) return -1; for(i = idx-1; i >= 0; --i) newenv[i] = environ[i]; virgin = 0; /* you're not a virgin anymore, sweety */ } else { newenv = (char **) realloc((char *) environ, (unsigned) ((idx + 2) * sizeof(char*))); if (newenv == 0) return -1; } environ = newenv; environ[idx] = s; environ[idx+1] = 0; return 0; }
static Widget _Ux_create_axisFormDialog() { Widget rtrn; _UxCaxisFormDialog *UxContext; UxAxisFormDialogContext = UxContext = (_UxCaxisFormDialog *) XtMalloc( sizeof(_UxCaxisFormDialog) ); rtrn = _Uxbuild_axisFormDialog(); return(rtrn); }
SaveData save_allocSaveData() { SaveData sd; Cardinal size = sizeof(SaveDataStruct); BEGINMESSAGE(save_alllocSaveData) sd = (SaveData) XtMalloc(size); memset((void*) sd ,0,(size_t)size); ENDMESSAGE(save_allocSaveData) return(sd); }
static XmStringTable CopyST (XmStringTable st, int nst) { XmStringTable lst = (XmStringTable) XtMalloc(sizeof(XmString) * nst); int i ; for (i=0; i < nst ; i++) { lst[i] = XmStringCopy(st[i]); } return lst ; }
static Boolean _putIntResource(ClientDBRec *clientDB, char *fmtStr, char *clientID, int resourceVal) { if (NULL == clientIDBuf) clientIDBuf = XtMalloc(RESOURCE_BUF_SZ); sprintf(clientIDBuf, fmtStr, clientID); if (fprintf(clientDB->xrmDBFile, "%s: %d\n", clientIDBuf, resourceVal) < 0) return False; return True; }
static char * savestr (const char *s) { char *n; if (!s) return 0; n = XtMalloc (strlen (s) + 1); if (n) strcpy (n, s); return n; }
static Widget _Ux_create_helpDialog() { Widget rtrn; _UxChelpDialog *UxContext; UxHelpDialogContext = UxContext = (_UxChelpDialog *) XtMalloc( sizeof(_UxChelpDialog) ); rtrn = _Uxbuild_helpDialog(); return(rtrn); }
static void freeUndoNodes(UndoBuffer *ub, UndoNode *nd) { if (!freeUndoNodesInner(ub, nd)) { /* nothing got freed */ return; } ub->noMemory = False; if (! emergencySpace) { /* In case we've used the reserve, try to get it back */ emergencySpace = XtMalloc(RESERVEDSPACE); } }
/*************************************<->************************************* * * static void OwnWMSelections () * * * Description: * ----------- * Get the selection ownership for each managed screen. The selection mwm * will own is WM_Si. * * Inputs: * ------ * * * * * Outputs: * ------ * * Comments: * -------- * * *************************************<->***********************************/ static void OwnWMSelections ( Time timestamp ) { int scr; wmGD.xa_WM = (Atom *) XtMalloc (wmGD.numScreens * (sizeof (Atom))); for (scr = 0; scr < wmGD.numScreens; scr++) { if (wmGD.Screens[scr].managed) { char wm_scr[8]; sprintf(wm_scr, "WM_S%d", DefaultScreen(DISPLAY)); wmGD.xa_WM[scr] = XInternAtom (DISPLAY, wm_scr, False); #ifdef MWM_WSM /* * This registers the callback to be invoked when a request * is made against a WSM Protocol target. The request * callback is stored by the WSM Protocol code and is * invoked in the convert routine (WMiConvert) below. * See WSMProcessProtoTargets(). */ WSMRegisterRequestCallback(DISPLAY, scr, HandleWsmConvertRequest, NULL); #endif /* * Own the selection through UTM. This sets-up a convert function * that is invoked when a convert request is made on this selection. * The convert function is specified in the drawing area's * XmNconvertCallback resource. */ XtAddCallback(wmGD.Screens[scr].utmShell, XmNconvertCallback, WMiConvertCB, NULL); if (! XmeNamedSource(wmGD.Screens[scr].utmShell, wmGD.xa_WM[scr], timestamp)) { Warning (((char *)GETMESSAGE(56, 6, "Failed to own WM_nn selection"))); } else { PRINT("Owning selection %s\n", wm_scr); } } } }