本文整理匯總了C++中BLOCK函數的典型用法代碼示例。如果您正苦於以下問題:C++ BLOCK函數的具體用法?C++ BLOCK怎麽用?C++ BLOCK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BLOCK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: PROGRAM
void PROGRAM()
{
GETTOKEN();
BLOCK(0);
if(TOKEN != periodsym)
{
ERROR("Error number 9, period expected.");
}
//the halt at the end of the program
printToFile(9, 0, 2);
}
示例2: SWFMovie_importCharacter
/*
* Import a character to the movie
* Imports characters from an other movie. filename (URL) points to a SWF
* file with exported characters.
*
* returns a SWFCharacter object
*/
SWFCharacter
SWFMovie_importCharacter(SWFMovie movie,
const char *filename /* URL to movie */,
const char *name /* idetifier of character */)
{
SWFCharacter res;
SWFImportBlock importer;
int id;
res = (SWFCharacter) malloc(sizeof(struct SWFCharacter_s));
SWFCharacterInit(res);
CHARACTERID(res) = id = ++SWF_gNumCharacters;
BLOCK(res)->type = SWF_DEFINESPRITE;
BLOCK(res)->writeBlock = NULL;
BLOCK(res)->complete = completeSWFImportCharacter;
BLOCK(res)->dtor = (destroySWFBlockMethod) destroySWFCharacter;
importer = SWFMovie_addImport(movie, filename, name, id);
SWFCharacter_addDependency(res, (SWFCharacter) importer);
return res;
}
示例3: read_file
// Extracts a file (PRG, SEQ) byte-by-byte to stdout.
void read_file(char *d, int track, int sector) {
char *b = BLOCK(d, track, sector);
while (b) {
if (b[0]) {
write(1, &b[2], 254);
} else {
write(1, &b[2], (unsigned char)b[1]-1);
}
b = nextblock(d, b);
}
}
示例4: bitmap_set
void bitmap_set(struct bitmap *self, size_t pos)
{
size_t block = BLOCK(pos);
if (block >= self->word_alloc) {
self->word_alloc = block * 2;
self->words = realloc(self->words, self->word_alloc);
}
self->words[block] |= MASK(pos);
}
示例5: init_matrix
/*
* init_matrix - Fill in matrix M with random values.
*/
static void init_matrix(Matrix M, int nb)
{
int I, J, K, i, j, k;
/* Initialize random number generator. */
srand(1);
/* For each element of each block, fill in random value. */
for (I = 0; I < nb; I++)
for (J = 0; J < nb; J++)
for (i = 0; i < BLOCK_SIZE; i++)
for (j = 0; j < BLOCK_SIZE; j++)
BLOCK(MATRIX(M, I, J), i, j) =
((double)rand()) / (double)RAND_MAX;
/* Inflate diagonal entries. */
for (K = 0; K < nb; K++)
for (k = 0; k < BLOCK_SIZE; k++)
BLOCK(MATRIX(M, K, K), k, k) *= 10.0;
}
示例6: SWFShape_addStyleHeader
void
SWFShape_addStyleHeader(SWFShape shape)
{
SWFOutput out = newSWFOutput();
SWFOutput_writeUInt16(out, CHARACTERID(shape));
SWFOutput_writeRect(out, SWFCharacter_getBounds(CHARACTER(shape)));
if (shape->isUsingNewStyles) {
shape->nFills2 = 0;
shape->nLines2 = 0;
}
SWFOutput_writeFillStyles(out, shape->fills2, shape->nFills2, BLOCK(shape)->type);
SWFOutput_writeLineStyles(out, shape->lines2, shape->nLines2, BLOCK(shape)->type);
/* prepend shape->out w/ shape header */
SWFOutput_setNext(out, shape->out);
shape->out = out;
}
示例7: SWFShape_addStyleHeader
void
SWFShape_addStyleHeader(SWFShape shape)
{
SWFOutput out = newSWFOutput();
SWFOutput_writeUInt16(out, CHARACTERID(shape));
SWFOutput_writeRect(out, SWFCharacter_getBounds(CHARACTER(shape)));
if(shape->useVersion == SWF_SHAPE4)
{
SWFOutput_writeRect(out, shape->edgeBounds);
SWFOutput_writeUInt8(out, shape->flags);
}
SWFOutput_writeFillStyles(out, shape->fills, shape->nFills,
BLOCK(shape)->type, shape->edgeBounds);
SWFOutput_writeLineStyles(out, shape->lines, shape->nLines, BLOCK(shape)->type);
/* prepend shape->out w/ shape header */
SWFOutput_setNext(out, shape->out);
shape->out = out;
}
示例8: font
/* font machinery:
if a regular font (outlines in fdb) is used, it is added to the textfield
as type Font and later converted to a FontChar
while a Font, characters can be added (embedded)
an Imported font stays as is, so does a BrowserFont
*/
void
SWFTextField_setFont(SWFTextField field, SWFBlock font)
{
if(font == NULL)
return;
if ( BLOCK(font)->type == SWF_BROWSERFONT )
{
field->fonttype = BrowserFont;
field->font.browserFont = (SWFBrowserFont)font;
SWFCharacter_addDependency((SWFCharacter)field, (SWFCharacter)font);
field->flags |= SWFTEXTFIELD_HASFONT;
}
else if ( BLOCK(font)->type == SWF_DEFINEFONT
|| BLOCK(font)->type == SWF_DEFINEFONT2)
{
SWFFontCharacter fc = (SWFFontCharacter)font;
if(checkSWFFontCharacter(fc))
{
SWF_warn("font is empty or has no layout information\n");
return;
}
field->fonttype = Imported;
field->font.fontchar = fc;
SWFCharacter_addDependency(
(SWFCharacter)field, (SWFCharacter)font);
field->flags |= SWFTEXTFIELD_HASFONT | SWFTEXTFIELD_USEFONT;
}
else if (BLOCK(font)->type == SWF_MINGFONT)
{
if(!(SWFFont_getFlags((SWFFont)font) & SWF_FONT_HASLAYOUT))
{
SWF_warn("font is empty or has no layout information\n");
return;
}
field->fonttype = Font;
field->font.font = (SWFFont)font;
field->flags |= SWFTEXTFIELD_HASFONT | SWFTEXTFIELD_USEFONT;
}
else
SWF_warn("SWFTextField_setFont: not a valid font object\n");
}
示例9: newSWFText2
/* only dif is type 2 allows transparency.. */
SWFText
newSWFText2()
{
SWFText text = newSWFText();
/* If malloc failed, return NULL to signify this */
if (NULL == text)
return NULL;
BLOCK(text)->type = SWF_DEFINETEXT2;
return text;
}
示例10: BLOCK
// Parte da esquerda
void block::FIRELEFT() {
e[0] = e[7] = true;
BLOCK(NR, 12, 0);
DOT(NR, 0, 0, 11, 31);
DOT(DR, 12, 0, 12);
DOT(UR, 12, 14, 14, 15);
DOT(NR, 14, 0, 23, 24);
DOT(NR, 15, 0, 25);
DOT(UR, 12, 0, 32);
DOT(DR, 12, 14, 34, 35);
}
示例11: morecore
/* Get neatly aligned memory, initializing or
growing the heap info table as necessary. */
static __ptr_t morecore (__malloc_size_t size)
{
__ptr_t result;
malloc_info *newinfo, *oldinfo;
__malloc_size_t newsize;
result = align (size);
if (result == NULL)
return NULL;
/* Check if we need to grow the info table. */
if ((__malloc_size_t) BLOCK ((char *) result + size) > heapsize)
{
newsize = heapsize;
while ((__malloc_size_t) BLOCK ((char *) result + size) > newsize)
newsize *= 2;
newinfo = (malloc_info *) align (newsize * sizeof (malloc_info));
if (newinfo == NULL)
{
(*__morecore) (-size);
return NULL;
}
MEMCPY (newinfo, _heapinfo, heapsize * sizeof (malloc_info));
MEMSET (&newinfo[heapsize], 0,
(newsize - heapsize) * sizeof (malloc_info));
oldinfo = _heapinfo;
newinfo[BLOCK (oldinfo)].busy.type = 0;
newinfo[BLOCK (oldinfo)].busy.info.size
= BLOCKIFY (heapsize * sizeof (malloc_info));
_heapinfo = newinfo;
/* Account for the _heapinfo block itself in the statistics. */
_bytes_used += newsize * sizeof (malloc_info);
++_chunks_used;
_free_internal (oldinfo);
heapsize = newsize;
}
_heaplimit = BLOCK ((char *) result + size);
return result;
}
示例12: _fusion_shmalloc
/* Allocate memory from the heap. */
void *
_fusion_shmalloc( shmalloc_heap *heap, size_t size )
{
void *result;
size_t block, blocks, lastblocks, start;
register size_t i;
struct list *next;
D_DEBUG_AT( Fusion_SHMHeap, "%s( %p, %zu )\n", __FUNCTION__, heap, size );
D_MAGIC_ASSERT( heap, shmalloc_heap );
/* Some programs will call shmalloc (0). We let them pass. */
if (size == 0)
return NULL;
if (size < sizeof (struct list))
size = sizeof (struct list);
/* Determine the allocation policy based on the request size. */
if (size <= BLOCKSIZE / 2) {
/* Small allocation to receive a fragment of a block.
Determine the logarithm to base two of the fragment size. */
register size_t log = 1;
--size;
while ((size /= 2) != 0)
++log;
/* Look in the fragment lists for a
free fragment of the desired size. */
next = heap->fraghead[log].next;
if (next != NULL) {
/* There are free fragments of this size.
Pop a fragment out of the fragment list and return it.
Update the block's nfree and first counters. */
result = (void *) next;
next->prev->next = next->next;
if (next->next != NULL)
next->next->prev = next->prev;
block = BLOCK (result);
if (--(heap->heapinfo[block].busy.info.frag.nfree) != 0)
heap->heapinfo[block].busy.info.frag.first = (unsigned long int)
((unsigned long int) ((char *) next->next - (char *) NULL)
% BLOCKSIZE) >> log;
/* Update the statistics. */
heap->chunks_used++;
heap->bytes_used += 1 << log;
heap->chunks_free--;
heap->bytes_free -= 1 << log;
}
else {
示例13: print_matrix
/*
* print_matrix - Print matrix M.
*/
static void print_matrix(Matrix M, int nb)
{
int i, j;
/* Print out matrix. */
for (i = 0; i < nb * BLOCK_SIZE; i++) {
for (j = 0; j < nb * BLOCK_SIZE; j++)
printf(" %6.4f",
BLOCK(MATRIX(M, i / BLOCK_SIZE, j / BLOCK_SIZE),
i % BLOCK_SIZE, j % BLOCK_SIZE));
printf("\n");
}
}
示例14: block_graph
/* block_graph:
* Add induced edges.
*/
static void block_graph(Agraph_t * g, block_t * sn)
{
Agnode_t *n;
Agedge_t *e;
Agraph_t *subg = sn->sub_graph;
for (n = agfstnode(subg); n; n = agnxtnode(subg, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
if (BLOCK(e->head) == sn)
aginsert(subg, e);
}
}
}
示例15: file_size
// Calculate exact file size by reading entire file.
// Fast since its all in ram.
int file_size(char *d, int track, int sector) {
int size = 0;
char *b = BLOCK(d, track, sector);
while (b) {
if (b[0]) {
size += 254;
} else {
size += (unsigned char)b[1]-1;
}
b = nextblock(d, b);
}
return size;
}