本文整理汇总了C++中wmalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ wmalloc函数的具体用法?C++ wmalloc怎么用?C++ wmalloc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wmalloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wmalloc
static Atom *getTypeAtomList(WMScreen * scr, WMView * view, int *count)
{
WMArray *types;
Atom *typeAtoms;
int i;
types = view->dragSourceProcs->dropDataTypes(view);
if (types != NULL) {
*count = WMGetArrayItemCount(types);
if (*count > 0) {
typeAtoms = wmalloc((*count) * sizeof(Atom));
for (i = 0; i < *count; i++) {
typeAtoms[i] = XInternAtom(scr->display, WMGetFromArray(types, i), False);
}
/* WMFreeArray(types); */
return typeAtoms;
}
/* WMFreeArray(types); */
}
*count = 1;
typeAtoms = wmalloc(sizeof(Atom));
*typeAtoms = None;
return typeAtoms;
}
示例2: _wilddog_url_getKey
/*
* Function: _wilddog_url_getKey
* Description: Get the Key of the path.
* Input: p_path: The path.
* Output: N/A
* Return: Pointer to the Key.
*/
Wilddog_Str_T * WD_SYSTEM _wilddog_url_getKey(Wilddog_Str_T * p_path)
{
int i, len, pos = 0;
Wilddog_Str_T* p_str = NULL;
if(NULL == p_path)
return NULL;
len = strlen((const char*)p_path);
if(len == 1 && p_path[0] == '/')
{
p_str = (Wilddog_Str_T*)wmalloc(len + 1);
if(NULL == p_str)
return NULL;
p_str[0] = '/';
return p_str;
}
for(i = len - 1; i >=0; i--)
{
if(p_path[len - 1] == '/')
continue;
if(p_path[i] == '/')
{
pos = i;
break;
}
}
p_str = (Wilddog_Str_T*)wmalloc(len - pos);
if(NULL == p_str)
return NULL;
memcpy((char*)p_str, (char*)(p_path + pos + 1), len - pos);
return p_str;
}
示例3: executeRepair_OneBlock
/*
** Perform Re-Pair on one block
*/
static void executeRepair_OneBlock (PROG_INFO *prog_struct, BLOCK_INFO *block_struct) {
R_UINT i;
/* Perform scanPairs */
scanPairs (prog_struct, block_struct);
/* Allocate queue and initialize to NULL */
/* Make the priority queue bigger by one since position 0 is
** unused. */
block_struct -> pqueue_size = block_struct -> max_count + 1;
block_struct -> pqueue = wmalloc ((block_struct -> pqueue_size) * (sizeof (TPHRASE*)));
for (i = 0; i < block_struct -> pqueue_size; i++) {
block_struct -> pqueue[i] = NULL;
}
/* Populate queue with tentative phrases */
initQueue (prog_struct, block_struct);
/* Recursively pair phrases */
rePairPhrases (prog_struct, block_struct);
/* Sort primitives */
sortPrimitives (block_struct);
block_struct -> sort_phrases = wmalloc (((block_struct -> num_prims) + (block_struct -> num_phrases)) * (sizeof (PHRASE)));
/* Sort phrases */
sortPhrases (prog_struct, block_struct);
return;
}
示例4: kqueue
static struct apiState *eventInit(int nevent)
{
struct kevent *events = NULL;
int ep;
struct apiState *state = NULL;
ep = kqueue();
if (ep < 0) {
return NULL;
}
state = wmalloc(sizeof(struct apiState));
if (!state) {
close(ep);
return NULL;
}
events = wmalloc(nevent*sizeof(struct kevent));
if (events == NULL) {
close(ep);
wfree(state);
return NULL;
}
state->kqfd = ep;
state->events = events;
return state;
}
示例5: addWMMenuEntryCallback
/* upon fully deducing one particular menu entry, parsers call back to this
* function to have said menu entry added to the wm menu. initializes wm menu
* with a root element if needed.
*/
static void addWMMenuEntryCallback(WMMenuEntry *aEntry)
{
WMMenuEntry *wm;
WMTreeNode *at;
wm = (WMMenuEntry *)wmalloc(sizeof(WMMenuEntry)); /* this entry */
at = (WMTreeNode *)NULL; /* will be a child of this entry */
if (!menu) {
WMMenuEntry *root;
root = (WMMenuEntry *)wmalloc(sizeof(WMMenuEntry));
root->Name = "Applications";
root->CmdLine = NULL;
root->SubMenu = NULL;
root->Flags = 0;
menu = WMCreateTreeNode(root);
}
if (aEntry->SubMenu)
at = findPositionInMenu(aEntry->SubMenu);
if (!at)
at = menu;
wm->Flags = aEntry->Flags;
wm->Name = wstrdup(aEntry->Name);
wm->CmdLine = wstrdup(aEntry->CmdLine);
wm->SubMenu = NULL;
WMAddItemToTree(at, wm);
}
示例6: wmalloc
WMTextField *WMCreateTextField(WMWidget * parent)
{
TextField *tPtr;
tPtr = wmalloc(sizeof(TextField));
tPtr->widgetClass = WC_TextField;
tPtr->view = W_CreateView(W_VIEW(parent));
if (!tPtr->view) {
wfree(tPtr);
return NULL;
}
tPtr->view->self = tPtr;
tPtr->view->delegate = &_TextFieldViewDelegate;
tPtr->view->attribFlags |= CWCursor;
tPtr->view->attribs.cursor = tPtr->view->screen->textCursor;
W_SetViewBackgroundColor(tPtr->view, tPtr->view->screen->white);
tPtr->text = wmalloc(MIN_TEXT_BUFFER);
tPtr->textLen = 0;
tPtr->bufferSize = MIN_TEXT_BUFFER;
tPtr->flags.enabled = 1;
WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | FocusChangeMask, handleEvents, tPtr);
tPtr->font = WMRetainFont(tPtr->view->screen->normalFont);
tPtr->flags.bordered = DEFAULT_BORDERED;
tPtr->flags.beveled = True;
tPtr->flags.alignment = DEFAULT_ALIGNMENT;
tPtr->offsetWidth = WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font)) / 2, 1);
W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
WMCreateEventHandler(tPtr->view, EnterWindowMask | LeaveWindowMask
| ButtonReleaseMask | ButtonPressMask | KeyPressMask | Button1MotionMask,
handleTextFieldActionEvents, tPtr);
WMAddNotificationObserver(selectionNotification, tPtr->view,
WMSelectionOwnerDidChangeNotification, (void *)XA_PRIMARY);
WMAddNotificationObserver(realizeObserver, tPtr, WMViewRealizedNotification, tPtr->view);
tPtr->flags.cursorOn = 1;
return tPtr;
}
示例7: wmalloc
WMHashTable *WMCreateHashTable(WMHashTableCallbacks callbacks)
{
HashTable *table;
table = wmalloc(sizeof(HashTable));
table->callbacks = callbacks;
table->size = INITIAL_CAPACITY;
table->table = wmalloc(sizeof(HashItem *) * table->size);
return table;
}
示例8: removeColumn
static void removeColumn(WMBrowser * bPtr, int column)
{
int i, clearEnd, destroyEnd;
WMList **clist;
char **tlist;
assert(bPtr != NULL);
column = (column < 0) ? 0 : column;
if (column >= bPtr->columnCount) {
return;
}
if (column < bPtr->maxVisibleColumns) {
clearEnd = bPtr->maxVisibleColumns;
destroyEnd = bPtr->columnCount;
bPtr->columnCount = bPtr->maxVisibleColumns;
} else {
clearEnd = column;
destroyEnd = bPtr->columnCount;
bPtr->columnCount = column;
}
if (column < bPtr->usedColumnCount) {
bPtr->usedColumnCount = column;
}
for (i = column; i < clearEnd; i++) {
if (bPtr->titles[i]) {
wfree(bPtr->titles[i]);
bPtr->titles[i] = NULL;
}
WMClearList(bPtr->columns[i]);
}
for (; i < destroyEnd; i++) {
if (bPtr->titles[i]) {
wfree(bPtr->titles[i]);
bPtr->titles[i] = NULL;
}
WMRemoveNotificationObserverWithName(bPtr, WMListSelectionDidChangeNotification, bPtr->columns[i]);
WMDestroyWidget(bPtr->columns[i]);
bPtr->columns[i] = NULL;
}
clist = wmalloc(sizeof(WMList *) * (bPtr->columnCount));
tlist = wmalloc(sizeof(char *) * (bPtr->columnCount));
memcpy(clist, bPtr->columns, sizeof(WMList *) * (bPtr->columnCount));
memcpy(tlist, bPtr->titles, sizeof(char *) * (bPtr->columnCount));
wfree(bPtr->titles);
wfree(bPtr->columns);
bPtr->titles = tlist;
bPtr->columns = clist;
}
示例9: wWorkspaceNew
int wWorkspaceNew(WScreen *scr)
{
WWorkspace *wspace, **list;
int i;
if (w_global.workspace.count < MAX_WORKSPACES) {
w_global.workspace.count++;
wspace = wmalloc(sizeof(WWorkspace));
wspace->name = NULL;
wspace->clip = NULL;
if (!wspace->name) {
static const char *new_name = NULL;
static size_t name_length;
if (new_name == NULL) {
new_name = _("Workspace %i");
name_length = strlen(new_name) + 8;
}
wspace->name = wmalloc(name_length);
snprintf(wspace->name, name_length, new_name, w_global.workspace.count);
}
if (!wPreferences.flags.noclip)
wspace->clip = wDockCreate(scr, WM_CLIP, NULL);
list = wmalloc(sizeof(WWorkspace *) * w_global.workspace.count);
for (i = 0; i < w_global.workspace.count - 1; i++)
list[i] = w_global.workspace.array[i];
list[i] = wspace;
if (w_global.workspace.array)
wfree(w_global.workspace.array);
w_global.workspace.array = list;
wWorkspaceMenuUpdate(w_global.workspace.menu);
wWorkspaceMenuUpdate(w_global.clip.ws_menu);
wNETWMUpdateDesktop(scr);
WMPostNotificationName(WMNWorkspaceCreated, scr, (void *)(uintptr_t) (w_global.workspace.count - 1));
XFlush(dpy);
return w_global.workspace.count - 1;
}
return -1;
}
示例10: strlen
/*
* Function: _wilddog_url_getParentStr
* Description: Get the Parent path of the source path.
* Input: p_src_path: The source path.
* Output: N/A
* Return: Pointer to the parent's path.
*/
STATIC Wilddog_Str_T * WD_SYSTEM _wilddog_url_getParentStr
(
Wilddog_Str_T* p_src_path
)
{
int i;
int size = 0;
int pos = 0;
Wilddog_Str_T* p_path = NULL;
if(!p_src_path)
return NULL;
size = strlen((const char*)p_src_path);
if(size == 1 && p_src_path[0] == '/')
{
return NULL;
}
for(i = size - 1; i >= 0; i--)
{
if(p_src_path[size - 1] == '/')
continue;
if(p_src_path[i] == '/')
{
pos = i;
break;
}
}
/* path do not have '/', invalid */
if((!pos) && (p_src_path[pos] != '/'))
return p_path;
if(pos == 0)
{
p_path = (Wilddog_Str_T *)wmalloc(2);
if(NULL == p_path)
return NULL;
p_path[0] = '/';
return p_path;
}
p_path = (Wilddog_Str_T *)wmalloc(pos + 1);
if(NULL == p_path)
return NULL;
strncpy((char*)p_path, (char*)p_src_path, pos);
return p_path;
}
示例11: registerDescriptionList
static void registerDescriptionList(WMScreen * scr, WMView * view, WMArray * operationArray)
{
char *text, *textListItem, *textList;
int count = WMGetArrayItemCount(operationArray);
int i;
int size = 0;
/* size of XA_STRING info */
for (i = 0; i < count; i++) {
size += strlen(WMGetDragOperationItemText(WMGetFromArray(operationArray, i))) + 1 /* NULL */;
}
/* create text list */
textList = wmalloc(size);
textListItem = textList;
for (i = 0; i < count; i++) {
text = WMGetDragOperationItemText(WMGetFromArray(operationArray, i));
wstrlcpy(textListItem, text, size);
/* to next text offset */
textListItem = &(textListItem[strlen(textListItem) + 1]);
}
XChangeProperty(scr->display,
WMViewXID(view),
scr->xdndActionDescriptionAtom,
XA_STRING,
XDND_ACTION_DESCRIPTION_FORMAT, PropModeReplace, (unsigned char *)textList, size);
}
示例12: _wilddog_conn_init
*/
Wilddog_Conn_T * WD_SYSTEM _wilddog_conn_init(Wilddog_Repo_T* p_repo)
{
Wilddog_CM_InitArg_T cm_initArg;
Wilddog_Conn_T* p_repo_conn = NULL;
if(!p_repo)
return NULL;
p_repo_conn = (Wilddog_Conn_T*)wmalloc(sizeof(Wilddog_Conn_T));
if( NULL ==p_repo_conn)
return NULL;
p_repo_conn->p_conn_repo = p_repo;
p_repo->p_rp_conn = p_repo_conn;
p_repo_conn->f_conn_ioctl = (Wilddog_Func_T)_wilddog_conn_ioctl;
cm_initArg.p_repo= p_repo;
cm_initArg.f_conn_cb = (Wilddog_Func_T)_wilddog_conn_cb_ioctl;
p_repo_conn->p_cm_l = (void*)_wilddog_cm_ioctl( CM_CMD_INIT,&cm_initArg,0);
if( p_repo_conn->p_cm_l == NULL )
{
wfree(p_repo_conn);
p_repo_conn = NULL;
}
return p_repo_conn;
示例13: get_texture_image
WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, const char *pixmap_file, XColor *color)
{
WTexPixmap *texture;
XGCValues gcv;
RImage *image;
image = get_texture_image(scr, pixmap_file);
if (!image)
return NULL;
texture = wmalloc(sizeof(WTexture));
texture->type = WTEX_PIXMAP;
texture->subtype = style;
texture->normal = *color;
XAllocColor(dpy, scr->w_colormap, &texture->normal);
gcv.background = gcv.foreground = texture->normal.pixel;
gcv.graphics_exposures = False;
texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground | GCBackground | GCGraphicsExposures, &gcv);
texture->pixmap = image;
return texture;
}
示例14: WMMaskEvents
WMMaskedEvents* WMMaskEvents(WMView* view) {
W_MaskedEvents *mask;
unsigned int i;
Bool changed = False;
mask = wmalloc(sizeof(W_MaskedEvents));
mask->view = view;
mask->procs = WMCreateArray(0);
mask->data = WMCreateArray(0);
for (i = 0; i < WMGetArrayItemCount(W_GetViewEventHandlers(view)); i++) {
W_EventHandler *h = (W_EventHandler*) WMGetFromArray(W_GetViewEventHandlers(view), i);
if (h->eventMask == (ButtonPressMask|ButtonReleaseMask|
EnterWindowMask|LeaveWindowMask|ButtonMotionMask)) {
WMAddToArray(mask->procs, h->proc);
WMAddToArray(mask->data, h->clientData);
/* we change only the first handler to our one, because they seem
to be processed upside-down and we want the dnd-handler to be processed
first. */
if (changed == False) {
h->proc = W_MaskedEventHandler;
h->clientData = (void*) mask;
changed = True;
} else {
WMDeleteEventHandler(view, h->eventMask, h->proc, h->clientData);
}
}
}
return mask;
}
示例15: wstrdup
Panel *InitMouseSettings(WMWidget *parent)
{
_Panel *panel;
modifierNames[0] = wstrdup(_("Shift"));
modifierNames[1] = wstrdup(_("Lock"));
modifierNames[2] = wstrdup(_("Control"));
modifierNames[3] = wstrdup(_("Mod1"));
modifierNames[4] = wstrdup(_("Mod2"));
modifierNames[5] = wstrdup(_("Mod3"));
modifierNames[6] = wstrdup(_("Mod4"));
modifierNames[7] = wstrdup(_("Mod5"));
panel = wmalloc(sizeof(_Panel));
panel->sectionName = _("Mouse Preferences");
panel->description = _("Mouse speed/acceleration, double click delay,\n" "mouse button bindings etc.");
panel->parent = parent;
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeData;
AddSection(panel, ICON_FILE);
return panel;
}