/* * Remove node succeeding another node. * * n precedes the node to be removed, data will point to the data * of the removed node. If n is null, the node at the head is removed. * Exits on error if l is empty or if removal is attempted at the list tail. */ int l_rem_next(LList *l, LNode *n, void **data) { LNode *oldNode; if (l_size(l) == 0) return -1; if (n == NULL) { oldNode = l->head; l->head = l->head->next; if (l_size(l) == 1) l->tail = NULL; } else { if (n->next == NULL) return -1; oldNode = n->next; n->next = n->next->next; if (n->next == NULL) l->tail = n; } *data = oldNode->data; free(oldNode); l->size--; return 0; }
/* * Insert a node succeeding another node. * * n precedes the node to be inserted, data holds data to be stored in the * inserted node. If n is null, the node is inserted at the head. * Exits on error if no space can be allocated for newNode. */ int l_ins_next(LList *l, LNode *n, const void *data) { LNode *newNode; if ((newNode = malloc(sizeof(*newNode))) == NULL) return -1; newNode->data = (void *)data; if (n == NULL) { if (l_size(l) == 0) l->tail = newNode; newNode->next = l->head; l->head = newNode; } else { if (n->next == NULL) l->tail = newNode; newNode->next = n->next; n->next = newNode; } l->size++; return 0; }
/* * Destroy all data in the list. * * No error checks, region of l is zeroed with memset. */ void l_drop(LList *l) { void *data; while (l_size(l) > 0) { if (l_rem_next(l, NULL, &data) == 0 && l->kill != NULL) l->kill(data); } memset(l, 0, sizeof(LList)); return; }
void l_display(List l){ if (l_size(l) == 0) printf("[ ] \n"); else{ Elem e = l->first; printf("["); if (e != NULL) printf("%d", e->val); e = e->next; while (e != NULL){ printf(", %d", e->val); e = e->next; } printf("]\n"); } }
void MainView::resizeContent(const QSize &s) { QSizeF l_size(s); QSizeF p_size(l_size.height(), l_size.width()); bool portrait = (m_angle%90 == 0) && (m_angle%180 != 0); if (portrait) { m_mainWidget->resize(p_size); m_backGround->resize(p_size); } else { m_mainWidget->resize(l_size); m_backGround->resize(l_size); } m_menu->setPos(m_topBar->getStatusBarLocation()); setSceneRect(QRectF(m_mainWidget->pos(), m_mainWidget->size())); }
uint renderer::create_texture(uint _format, pointer _data, uint _width, uint _height, uint _pitch) { texture l_texture; l_texture.width = _width; l_texture.height = _height; l_texture.texture_ID = m_video.spawn(m_texture); l_texture.texset_ID = m_video.spawn(m_texset); m_video.get_<vo::texset>(l_texture.texset_ID).set_texture(0, l_texture.texture_ID); l_texture.memreader_ID = m_video.spawn(m_memreader); m_video.get_<vo::texture>(l_texture.texture_ID).set_source(l_texture.memreader_ID); vo::memreader &l_memreader = m_video.get_<vo::memreader>(l_texture.memreader_ID); l_memreader.write(&_format, sizeof(_format)); sint2 l_size(_width, _height); l_memreader.write(&l_size, sizeof(l_size)); l_memreader.write(&_pitch, sizeof(_pitch)); l_memreader.write(_data, _height * _pitch); return m_textures.add(l_texture); }
/************************************************************************ * GETNUM - Get a number from the input stream. * * ARGUMENTS * radix - the radix of the number to be accumulated. Can only be 8, 10, * or 16 * pval - a pointer to a VALUE union to be filled in with the value * * RETURNS - type of the token (L_CINTEGER or L_CFLOAT) * * SIDE EFFECTS - * does push back on the input stream. * writes into pval by reference * uses buffer Reuse_W * * DESCRIPTION - * Accumulate the number according to the rules for each radix. * Set up the format string according to the radix (or distinguish * integer from float if radix is 10) and convert to binary. * * AUTHOR - Ralph Ryan, Sept. 8, 1982 * * MODIFICATIONS - none * ************************************************************************/ token_t getnum(REG WCHAR c) { REG WCHAR *p; WCHAR *start; int radix; token_t tok; value_t value; tok = L_CINTEGER; start = (Tiny_lexer_nesting ? Exp_ptr : Reuse_W); p = start; if( c == L'0' ) { c = get_non_eof(); if( IS_X(c) ) { radix = 16; if( Prep ) { *p++ = L'0'; *p++ = L'x'; } for(c = get_non_eof(); LXC_IS_XDIGIT(c); c = get_non_eof()) { /* no check for overflow? */ *p++ = c; } if((p == Reuse_W) && (Tiny_lexer_nesting == 0)) { strcpy (Msg_Text, GET_MSG (2153)); error(2153); } goto check_suffix; } else { radix = 8; *p++ = L'0'; /* for preprocessing or 0.xxx case */ } } else { radix = 10; } while( LXC_IS_DIGIT((WCHAR)c) ) { *p++ = c; c = get_non_eof(); } if( IS_DOT(c) || IS_E(c) ) { UNGETCH(); return(get_real(p)); } check_suffix: if( IS_EL(c) ) { if( Prep ) { *p++ = c; } c = get_non_eof(); if( IS_U(c) ) { if(Prep) { *p++ = c; } tok = L_LONGUNSIGNED; } else { tok = L_LONGINT; UNGETCH(); } } else if( IS_U(c) ) { if( Prep ) { *p++ = c; } c = get_non_eof(); if( IS_EL(c) ) { if( Prep ) { *p++ = c; } tok = L_LONGUNSIGNED; } else { tok = L_CUNSIGNED; UNGETCH(); } } else { UNGETCH(); } *p = L'\0'; if( start == Exp_ptr ) { Exp_ptr = p; return(L_NOTOKEN); } else if( Prep ) { myfwrite( Reuse_W, (size_t)(p - Reuse_W) * sizeof(WCHAR), 1, OUTPUTFILE); return(L_NOTOKEN); } value.v_long = matol(Reuse_W,radix); switch(tok) { case L_CINTEGER: tok = (radix == 10) ? c_size(value.v_long) : uc_size(value.v_long) ; break; case L_LONGINT: tok = l_size(value.v_long); break; case L_CUNSIGNED: tok = ul_size(value.v_long); break; } yylval.yy_tree = build_const(tok, &value); return(tok); }