void make_map(int map[21][21], char *output, int chsec) { int x,y; char *result; sprintf(output, "\r\n%s\r\n", "-----------------------"); for(y=0;y<21;y++) { strcat(output, "|"); for(x=0;x<21;x++) { switch(map[x][y]) { case 100: strcat(output, " "); break; case 75: strcat(output, "\x1B[39;1m:\x1B[0m"); break; case 50: result = get_buffer(64); sprintf(result, "\x1B[%s;31;1m@\x1B[0m", scodes[chsec].back); strcat(output, result); release_buffer(result); break; default: result = get_buffer(64); sprintf(result,"\x1B[%s;%sm%s\x1B[0m", scodes[map[x][y]].back, scodes[map[x][y]].fore, scodes[map[x][y]].sym); strcat(output, result); release_buffer(result); break; } } strcat(output, "|\r\n"); } strcat(output,"-----------------------\r\n"); }
int find_help_entry(const char *argument) { int rec_count; MYSQL_RES *helpindex; char *searcharg=NULL, *line; if (!*argument) return (0); line = str_dup(argument); SQL_MALLOC(LOWERALL(line), searcharg); SQL_ESC(LOWERALL(line), searcharg); if (!(helpindex = mysqlGetResource(TABLE_HLP_INDEX, "SELECT keyword FROM %s WHERE keyword LIKE '%%%s%%' LIMIT 1;", TABLE_HLP_INDEX, searcharg))) { if (*searcharg) SQL_FREE(searcharg); release_buffer(line); return (0); } release_buffer(line); rec_count = mysql_num_rows(helpindex); mysql_free_result(helpindex); if (*searcharg) SQL_FREE(searcharg); if (rec_count == 1) return (1); return (0); }
static int cdfs_find_in_dir(struct cdfs *cdfs, int dir, char *name, int len, struct buf **dirbuf, struct iso_directory_record **dirrec) { struct buf *buf; char *p; struct iso_directory_record *rec; int blk; int left; int reclen; int namelen; // The first two directory records are . (current) and .. (parent) blk = cdfs->path_table[dir]->extent; buf = get_buffer(cdfs->cache, blk++); if (!buf) return -EIO; // Get length of directory from the first record p = buf->data; rec = (struct iso_directory_record *) p; left = isonum_733(rec->size); // Find named entry in directory while (left > 0) { // Read next block if all records in current block has been read // Directory records never cross block boundaries if (p >= buf->data + CDFS_BLOCKSIZE) { release_buffer(cdfs->cache, buf); if (p > buf->data + CDFS_BLOCKSIZE) return -EIO; buf = get_buffer(cdfs->cache, blk++); if (!buf) return -EIO; p = buf->data; } // Check for match rec = (struct iso_directory_record *) p; reclen = isonum_711(rec->length); namelen = isonum_711(rec->name_len); if (reclen > 0) { if (cdfs_fnmatch(cdfs, name, len, (char *) rec->name, namelen)) { *dirrec = rec; *dirbuf = buf; return 0; } // Skip to next record p += reclen; left -= reclen; } else { // Skip to next block left -= (buf->data + CDFS_BLOCKSIZE) - p; p = buf->data + CDFS_BLOCKSIZE; } } release_buffer(cdfs->cache, buf); return -ENOENT; }
void list_wands_staves (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; char *wsbuf = get_buffer(MAX_STRING_LENGTH); skip_spaces(&input); switch (input[0]) { case 'T': case 't': type = ITEM_STAFF; break; case 'W': case 'w': type = ITEM_WAND; break; default: extended_mudlog(NRM, SYSL_BUGS, TRUE, "Default reached in list_scrolls_potions (arg = %s)", input); release_buffer(wsbuf); return; } /*switch...*/ wsbuf[0]='\0'; for (i=0;i<top_of_objt;i++) { j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/ if (j == type) { /*found one*/ sprintf(wsbuf+strlen(wsbuf),"[%5d] %-30s", /*print vnum, short description*/ GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); /* * values 0-3: * Potion, Scroll - up to three spells [values 1-3] */ sprintf(wsbuf+strlen(wsbuf), " Spells: "); if (type==ITEM_STAFF) { /*staves have only one spell*/ if ((GET_OBJ_VAL(&obj_proto[i], 3)) != (-1)) sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], 3))); } else { for (k=1; k < 4; k++) { if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1)) sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k))); } sprintf(wsbuf+strlen(wsbuf), "\r\n"); } } /*if j == type*/ } /*for i...*/ page_string (ch->desc, wsbuf, 1); release_buffer(wsbuf); }
int BIKPlayer::EndVideo() { int i; release_buffer(&c_pic); release_buffer(&c_last); for (i = 0; i < BINK_NB_SRC; i++) { av_freep((void **) &c_bundle[i].data); } video->DrawMovieSubtitle(0); return 0; }
void list_scrolls_potions (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; char *spbuf = get_buffer(MAX_STRING_LENGTH); skip_spaces(&input); switch (input[0]) { case 'S': case 's': type = ITEM_SCROLL; break; case 'P': case 'p': type = ITEM_POTION; break; default : mlog("SYSERR: Default reached in list_scrolls_potions (arg = %s)", input); release_buffer(spbuf); return; }/*switch...*/ spbuf[0]='\0'; for (i=0;i<top_of_objt;i++) { j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/ if (j == type) { /*found one*/ sprintf(spbuf+strlen(spbuf),"[%5d] %-20s", /*print vnum, short description*/ GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); /* * values 0-3: * Potion, Scroll - up to three spells [values 1-3] */ sprintf(spbuf+strlen(spbuf), " Spells: "); for (k=1;k<4;k++) { if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1)) sprintf(spbuf+strlen(spbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k))); } sprintf(spbuf+strlen(spbuf), "\r\n"); }/*if j == type*/ }/*for i...*/ page_string (ch->desc, spbuf, 1); release_buffer(spbuf); }
void do_list_wear (struct char_data *ch, char *input) { char j = atoi(input); int i=0; char *wbuf = get_buffer(MAX_STRING_LENGTH); if (input[0] == '?') { j=0; send_to_char ("Wear positions:\r\n", ch); for (i = 0; i < NUM_ITEM_WEARS; i++) { sprintf(buf, "(%2d) %-20.20s %s", i + 1, wear_bits[i], !(++j % 2) ? "\r\n" : ""); send_to_char(buf, ch); } send_to_char("\r\nIf you choose TAKE, you will be shown item that are !Take\r\n",ch); release_buffer(wbuf); return; } wbuf[0]='\0'; j--; /*to be used with NAMES array*/ if (j==0) { /*Show ony !Take items for this option*/ for (i=0;i<top_of_objt;i++) /*cycle through every obj*/ if (!(CAN_WEAR(&obj_proto[i], (1<<j)))) { /*check exact bit for requested position*/ sprintf(wbuf+strlen(wbuf),"[%5d] %-32s !TAKE\r\n", GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); } page_string (ch->desc, wbuf, 1); release_buffer(wbuf); return; } for (i=0;i<top_of_objt;i++) { /*cycle through every obj*/ if (CAN_WEAR(&obj_proto[i], (1<<j))) { /*check exact bit for requested position*/ sprintf(wbuf+strlen(wbuf),"[%5d] %-32s ", GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); sprintf(wbuf+strlen(wbuf),"%s\r\n", wear_bits[(int)j]); /*repeat position*/ } } if (!buf) send_to_char("There are no items of that type in the object files.c",ch); page_string (ch->desc, wbuf, 1); release_buffer(wbuf); }
int cdfs_stat(struct fs *fs, char *name, struct stat64 *buffer) { struct cdfs *cdfs = (struct cdfs *) fs->data; struct iso_directory_record *rec; struct buf *buf; int rc; int size; rc = cdfs_find_file(cdfs, name, strlen(name), &buf, &rec); if (rc < 0) return rc; size = isonum_733(rec->size); if (buffer) { memset(buffer, 0, sizeof(struct stat64)); if (rec->flags[0] & 2) { buffer->st_mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; } else { buffer->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; } buffer->st_ino = isonum_733(rec->extent); buffer->st_nlink = 1; buffer->st_dev = cdfs->devno; buffer->st_atime = buffer->st_mtime = buffer->st_ctime = cdfs_isodate(rec->date); buffer->st_size = size; }; release_buffer(cdfs->cache, buf); return size; }
drm_intel_bo * intel_bufferobj_buffer(struct intel_context *intel, struct intel_buffer_object *intel_obj, GLuint flag) { if (intel_obj->region) { if (flag == INTEL_WRITE_PART) intel_bufferobj_cow(intel, intel_obj); else if (flag == INTEL_WRITE_FULL) { intel_bufferobj_release_region(intel, intel_obj); intel_bufferobj_alloc_buffer(intel, intel_obj); } } if (intel_obj->source) release_buffer(intel_obj); if (intel_obj->buffer == NULL) { intel_bufferobj_alloc_buffer(intel, intel_obj); drm_intel_bo_subdata(intel_obj->buffer, 0, intel_obj->Base.Size, intel_obj->sys_buffer); free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL; intel_obj->offset = 0; } return intel_obj->buffer; }
// ------------------------------------------------ // Function: smtp_from() // ------------------------------------------------ // Input: Sender email address // Output: TRUE if succesful // ------------------------------------------------ // Description: Adds one MAIL FROM clause // ------------------------------------------------ BOOL smtp_from(char *s) { PPBUF buf; BOOL res; if(smtp_state != SMTP_FROM) return FALSE; // ---------------------- // send MAIL FROM command // ---------------------- buf = tcp_new(SOCKET_SMTP); if(buf == NULL) return FALSE; write_string(buf, "MAIL FROM:<"); write_string(buf, s); write_string(buf, ">\r\n"); res = tcp_send(SOCKET_SMTP, buf); release_buffer(buf); if(!res) return FALSE; if(!smtp_ok()) return FALSE; smtp_state = SMTP_RCPT; return TRUE; }
int cdfs_opendir(struct file *filp, char *name) { struct cdfs *cdfs = (struct cdfs *) filp->fs->data; struct iso_directory_record *rec; struct cdfs_file *cdfile; struct buf *buf; time_t date; int size; int extent; int flags; int rc; // Locate directory rc = cdfs_find_file(cdfs, name, strlen(name), &buf, &rec); if (rc < 0) return rc; flags = isonum_711(rec->flags); extent = isonum_733(rec->extent); date = cdfs_isodate(rec->date); size = isonum_733(rec->size); release_buffer(cdfs->cache, buf); if (!(flags & 2)) return -ENOTDIR; // Allocate and initialize file block cdfile = (struct cdfs_file *) kmalloc(sizeof(struct cdfs_file)); if (!cdfile) return -ENOMEM; cdfile->extent = extent; cdfile->date = date; cdfile->size = size; filp->data = cdfile; filp->mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; return 0; }
/** * @brief read process stderr * @param c the child to read stderr from * @returns 0 on success, -1 on error. */ int read_stderr(child_node *c) { buffer bigbuff; char buff[255]; char *line; int count, ret; ret = 0; memset(&(bigbuff), 0, sizeof(buffer)); while((count=read(c->stderr_fd, buff, 255)) > 0) { if(append_to_buffer(&(bigbuff), buff, count)) { ret = -1; goto exit; } while((line = get_line_from_buffer(&(bigbuff)))) { ret = on_cmd_stderr(c, line); free(line); if(ret) goto exit; } } exit: if(count<0) { print( ERROR, "read: %s", strerror(errno)); ret = -1; } release_buffer(&(bigbuff)); return ret; }
/** * The BufferData() driver hook. * * Implements glBufferData(), which recreates a buffer object's data store * and populates it with the given data, if present. * * Any data that was previously stored in the buffer object is lost. * * \return true for success, false if out of memory */ static GLboolean intel_bufferobj_data(struct gl_context * ctx, GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage, struct gl_buffer_object *obj) { struct brw_context *brw = brw_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); /* Part of the ABI, but this function doesn't use it. */ (void) target; intel_obj->Base.Size = size; intel_obj->Base.Usage = usage; assert(!obj->Pointer); /* Mesa should have unmapped it */ if (intel_obj->buffer != NULL) release_buffer(intel_obj); if (size != 0) { intel_bufferobj_alloc_buffer(brw, intel_obj); if (!intel_obj->buffer) return false; if (data != NULL) drm_intel_bo_subdata(intel_obj->buffer, 0, size, data); } return true; }
/** * Replace data in a subrange of buffer object. If the data range * specified by size + offset extends beyond the end of the buffer or * if data is NULL, no copy is performed. * Called via glBufferSubDataARB(). */ static void intel_bufferobj_subdata(struct gl_context * ctx, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); bool busy; if (size == 0) return; assert(intel_obj); /* If we have a single copy in system memory, update that */ if (intel_obj->sys_buffer) { if (intel_obj->source) release_buffer(intel_obj); if (intel_obj->buffer == NULL) { memcpy((char *)intel_obj->sys_buffer + offset, data, size); return; } free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL; } /* Otherwise we need to update the copy in video memory. */ busy = drm_intel_bo_busy(intel_obj->buffer) || drm_intel_bo_references(intel->batch.bo, intel_obj->buffer); if (busy) { if (size == intel_obj->Base.Size) { /* Replace the current busy bo with fresh data. */ drm_intel_bo_unreference(intel_obj->buffer); intel_bufferobj_alloc_buffer(intel, intel_obj); drm_intel_bo_subdata(intel_obj->buffer, 0, size, data); } else { perf_debug("Using a blit copy to avoid stalling on %ldb " "glBufferSubData() to a busy buffer object.\n", (long)size); drm_intel_bo *temp_bo = drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64); drm_intel_bo_subdata(temp_bo, 0, size, data); intel_emit_linear_blit(intel, intel_obj->buffer, offset, temp_bo, 0, size); drm_intel_bo_unreference(temp_bo); } } else { drm_intel_bo_subdata(intel_obj->buffer, offset, size, data); } }
// ------------------------------------------------ // Function: ping_request() // ------------------------------------------------ // Input: IP address // Network interface ID // Output: - // ------------------------------------------------ // Description: Sends a ping request message // ------------------------------------------------ void ping_request(IPV4 ip, BYTE interface) { PPBUF buf; buf = ip_new(ip, 64, interface); if(buf == NULL) return; // --------------------- // assemble ICMP message // --------------------- IPH(buf->start)->prot = IP_PROT_ICMP; ICMP(buf->data)->type = PING_REQUEST; ICMP(buf->data)->code = 0; ICMP(buf->data)->checksum = 0; ICMP(buf->data)->id = random(); ICMP(buf->data)->seq = random(); buf->size = sizeof(ICMP_HDR); // ------------------ // calculate checksum // ------------------ icmp_checksum(buf->data, buf->size); ICMP(buf->data)->checksum = HTONS(~WORDOF(chk_H, chk_L)); // ----------------------------- // sends message to IP interface // ----------------------------- ip_send(buf); release_buffer(buf); }
static ssize_t bio_do_io(struct bio_vec *vec, char *iobuf, size_t len, size_t pos, int rw) { size_t nr_bytes = 0; blkcnt_t blocks = io_block_count(vec->blksize, pos, len); blkcnt_t first_block = io_off_to_block(vec->blksize, pos); off_t start = io_block_off(vec->blksize, pos); off_t end = MIN((unsigned long)vec->blksize, start + len); for (blkcnt_t b = first_block; b - first_block < blocks; b++) { // do I/O within a single block struct buffer *buffer = read_block(vec->dev, vec->block[b], vec->blksize); if (rw == READ) { memcpy(iobuf+nr_bytes, buffer->b_data+start, end-start); } else { memcpy(buffer->b_data+start, iobuf+nr_bytes, end-start); buffer->b_flags |= BUF_DIRTY; } release_buffer(buffer); // update counts nr_bytes += end - start; start = 0; end = MIN((unsigned long)vec->blksize, len - nr_bytes); } return nr_bytes; }
int dfs_write(struct file *filp, void *data, size_t size) { struct inode *inode; size_t written; size_t count; char *p; unsigned int iblock; unsigned int start; vfs_blkno_t blk; struct buf *buf; inode = (struct inode *) filp->data; written = 0; p = (char *) data; while (size > 0) { iblock = filp->pos / inode->fs->blocksize; start = filp->pos % inode->fs->blocksize; count = inode->fs->blocksize - start; if (count > size) count = size; if (iblock < inode->desc->blocks) blk = get_inode_block(inode, iblock); else if (iblock == inode->desc->blocks) blk = expand_inode(inode); else return written; if (blk == -1) return written; if (count == inode->fs->blocksize) buf = alloc_buffer(inode->fs->cache, blk); else buf = get_buffer(inode->fs->cache, blk); if (!buf) return written; memcpy(buf->data + start, p, count); filp->flags |= F_MODIFIED; mark_buffer_updated(buf); release_buffer(inode->fs->cache, buf); filp->pos += count; p += count; written += count; size -= count; if (filp->pos > inode->desc->size) { inode->desc->size = filp->pos; mark_inode_dirty(inode); } } return written; }
int main(int argc, char* argv[]) { SharedVariable v; int runningTimeInSec = 10; if (argc == 2) { runningTimeInSec = atoi(argv[1]); } if (wiringPiSetup() == -1) { printf("Failed to setup wiringPi."); return 1; } printf("start"); // Initialize for the interfaces provided signal(SIGINT, signal_handler); init_deferred_buffer(1024*1024); // 1MB init_userspace_governor(); init_workload(); printf("stop"); // Initializers that you need to implement init_shared_variable(&v); init_sensors(&v); learn_workloads(&v); printf("Init scheduler start"); // Init scheduler int aliveTasks[NUM_TASKS]; init_scheduler(runningTimeInSec); set_by_max_freq(); // reset to the max freq printf("Init scheduler stop"); printDBG("Start Scheduling with %d threads\n", NUM_TASKS); TaskSelection sel; long long idleTime; while (v.bProgramExit != 1) { // 1. Prepare tasks idleTime = prepare_tasks(aliveTasks, &v); if (idleTime < 0) break; // 2. Select a process: You need to implement. sel = select_task(&v, aliveTasks, idleTime); if (sel.task < 0) break; // 3. Run the selected task execute_task(sel); } finish_workload(); release_buffer(fileno(stdout)); printf("Scheduler program finished.\n"); return 0; }
/* * Help categories are fairly static, and it would be a pain to execute another * query just to get them, so we've already read them in in db.c into an array, * and here we just loop them over. * Torgny Bjers, 2001-11-12 */ void display_help_categories(struct char_data *ch) { int qend, i; char *name, *help = get_buffer(MAX_STRING_LENGTH); MYSQL_RES *stats; MYSQL_ROW row; int numentries = 0; time_t modified; strcpy(help, "&CARCANE REALMS HELP TOPICS&n\r\n\r\nType 'HELP <topic>' for more information on a specific topic.\r\nYou can use HELP ? <search phrase> to issue a fulltext search.\r\n\r\n"); for (qend = 0, i = 0; i <= top_of_help_categories; i++) { if (!GOT_RIGHTS(ch, help_categories[i].rights) && !GOT_RIGHTS(ch, RIGHTS_HELPFILES)) continue; name = str_dup(help_categories[i].name); sprintf(help + strlen(help), "%s%-22.22s", ((qend % 3 == 0)?" ":""), ALLCAP(name)); release_buffer(name); if (qend++ % 3 == 2) { strcat(help, "\r\n"); send_to_char(help, ch); *help = '\0'; } } if (*help) send_to_char(help, ch); if (!(--qend % 3 == 2)) send_to_char("\r\n", ch); *help = '\0'; release_buffer(help); if (!(stats = mysqlGetResource(TABLE_HLP_INDEX, "SELECT COUNT(keyword) AS count, MAX(modified) AS modfied FROM %s ORDER BY modified;", TABLE_HLP_INDEX))) { send_to_char("&YA database error has occured. Please notify an administrator.&n\r\n", ch); extended_mudlog(NRM, SYSL_BUGS, TRUE, "Error loading help statistics."); return; } mysql_free_result(stats); row = mysql_fetch_row(stats); modified = atoi(row[1]); numentries = atoi(row[0]); send_to_charf(ch, "\r\nThere are &W%d&n help entries, latest updated: &W%s&n", numentries, ctime(&modified)); }
static OMX_ERRORTYPE dirble_prc_port_flush (const void * ap_obj, OMX_U32 TIZ_UNUSED (a_pid)) { dirble_prc_t * p_prc = (dirble_prc_t *) ap_obj; if (p_prc->p_trans_) { tiz_urltrans_flush_buffer (p_prc->p_trans_); } return release_buffer (p_prc); }
static void buffer_filled (OMX_BUFFERHEADERTYPE * ap_hdr, void * ap_arg) { dirble_prc_t * p_prc = ap_arg; assert (p_prc); assert (ap_hdr); assert (p_prc->p_outhdr_ == ap_hdr); ap_hdr->nOffset = 0; (void) release_buffer (p_prc); }
/* Break the COW tie to the region. The region gets to keep the data. */ void intel_bufferobj_release_region(struct intel_context *intel, struct intel_buffer_object *intel_obj) { assert(intel_obj->region->buffer == intel_obj->buffer); intel_obj->region->pbo = NULL; intel_obj->region = NULL; release_buffer(intel_obj); }
/** * Called via glMapBufferARB(). */ static void * intel_bufferobj_map(struct gl_context * ctx, GLenum target, GLenum access, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); GLboolean read_only = (access == GL_READ_ONLY_ARB); GLboolean write_only = (access == GL_WRITE_ONLY_ARB); assert(intel_obj); if (intel_obj->sys_buffer) { if (!read_only && intel_obj->source) { release_buffer(intel_obj); } if (!intel_obj->buffer || intel_obj->source) { obj->Pointer = intel_obj->sys_buffer; obj->Length = obj->Size; obj->Offset = 0; return obj->Pointer; } free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL; } /* Flush any existing batchbuffer that might reference this data. */ if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer)) intel_flush(ctx); if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); if (intel_obj->buffer == NULL) { obj->Pointer = NULL; return NULL; } if (write_only) { drm_intel_gem_bo_map_gtt(intel_obj->buffer); intel_obj->mapped_gtt = GL_TRUE; } else { drm_intel_bo_map(intel_obj->buffer, !read_only); intel_obj->mapped_gtt = GL_FALSE; } obj->Pointer = intel_obj->buffer->virtual; obj->Length = obj->Size; obj->Offset = 0; return obj->Pointer; }
/** * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If data is NULL, * memory will be allocated, but no copy will occur. * Called via ctx->Driver.BufferData(). * \return true for success, false if out of memory */ static GLboolean intel_bufferobj_data(struct gl_context * ctx, GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); /* Part of the ABI, but this function doesn't use it. */ #ifndef I915 (void) target; #endif intel_obj->Base.Size = size; intel_obj->Base.Usage = usage; assert(!obj->Pointer); /* Mesa should have unmapped it */ if (intel_obj->buffer != NULL) release_buffer(intel_obj); free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL; if (size != 0) { if (usage == GL_DYNAMIC_DRAW #ifdef I915 /* On pre-965, stick VBOs in system memory, as we're always doing * swtnl with their contents anyway. */ || target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER #endif ) { intel_obj->sys_buffer = malloc(size); if (intel_obj->sys_buffer != NULL) { if (data != NULL) memcpy(intel_obj->sys_buffer, data, size); return true; } } intel_bufferobj_alloc_buffer(intel, intel_obj); if (!intel_obj->buffer) return false; if (data != NULL) drm_intel_bo_subdata(intel_obj->buffer, 0, size, data); } return true; }
int dfs_readdir(struct file *filp, struct vfs_dirent *dirp, int count) { unsigned int iblock; unsigned int start; struct inode *inode; vfs_blkno_t blk; struct buf *buf; struct dentry *de; inode = (struct inode *) filp->data; if (count != 1) return -1; if (filp->pos == inode->desc->size) return 0; if (filp->pos > inode->desc->size) return -1; iblock = filp->pos / inode->fs->blocksize; start = filp->pos % inode->fs->blocksize; blk = get_inode_block(inode, iblock); if (blk == -1) return -1; buf = get_buffer(inode->fs->cache, blk); if (!buf) return -1; de = (struct dentry *) (buf->data + start); if (de->reclen + start > inode->fs->blocksize || de->namelen <= 0 || de->namelen >= MAXPATH) { release_buffer(inode->fs->cache, buf); return -1; } dirp->ino = de->ino; dirp->reclen = de->reclen; dirp->namelen = de->namelen; memcpy(dirp->name, de->name, de->namelen); dirp->name[de->namelen] = 0; filp->pos += de->reclen; release_buffer(inode->fs->cache, buf); return 1; }
void invalidate_buffer(struct bufpool *pool, vfs_blkno_t blkno) { struct buf *buf; // If buffer is not in cache we are finished buf = lookup_buffer(pool, blkno); if (!buf) return; // Mark buffer as invalid and release it mark_buffer_invalid(buf); release_buffer(pool, buf); }
static OMX_ERRORTYPE dirble_prc_stop_and_return (void * ap_prc) { dirble_prc_t * p_prc = ap_prc; assert (p_prc); if (p_prc->p_trans_) { tiz_urltrans_pause (p_prc->p_trans_); tiz_urltrans_flush_buffer (p_prc->p_trans_); } return release_buffer (p_prc); }
vfs_ino_t modify_dir_entry(struct inode *dir, char *name, int len, vfs_ino_t ino) { unsigned int block; vfs_blkno_t blk; struct buf *buf; char *p; struct dentry *de; vfs_ino_t oldino; if (len <= 0 || len >= MAXPATH) return -1; if (!VFS_S_ISDIR(dir->desc->mode)) return -1; for (block = 0; block < dir->desc->blocks; block++) { blk = get_inode_block(dir, block); buf = get_buffer(dir->fs->cache, blk); if (!buf) return -1; p = buf->data; while (p < buf->data + dir->fs->blocksize) { de = (struct dentry *) p; if (fnmatch(name, len, de->name, de->namelen)) { oldino = de->ino; de->ino = ino; mark_buffer_updated(buf); release_buffer(dir->fs->cache, buf); return oldino; } p += de->reclen; } release_buffer(dir->fs->cache, buf); } return -1; }
/* * Display main menu. */ void hedit_disp_menu(struct descriptor_data *d) { struct house_data *house; char *name; house = OLC_HOUSE(d); get_char_colors(d->character); if ((name = get_name_by_id(H_OWNER(house))) == NULL) name = str_dup("nobody"); else name = str_dup(get_name_by_id(H_OWNER(house))); clear_screen(d); write_to_output(d, TRUE, "-- House Number : [%s%d%s]\r\n" "%s0%s) Owner : %s%s\r\n" "%s1%s) Atrium : [%s%d%s] %s%s\r\n" "%s2%s) Exit : [%s%d%s] %s%s\r\n" "%s3%s) House type : %s%s\r\n" "%s4%s) Prune-safe : %s%s\r\n" "%s5%s) Cost : [%s%d%s]\r\n" "%s6%s) Max Secure containers : [%s%d%s]\r\n" "%s7%s) Max Locked-down objs : [%s%d%s]\r\n" "%sR%s) Rooms Menu\r\n" "%sC%s) Co-Owners Menu\r\n" "%sG%s) Guests Menu\r\n" "%sD%s) Delete this house\r\n" "%sQ%s) Quit\r\n" "Enter Choice : ", cyn, OLC_NUM(d), nrm, grn, nrm, yel, CAP(name), grn, nrm, cyn, real_room(H_ATRIUM(house)) == NOWHERE ? -1 : world[real_room(H_ATRIUM(house))].number, nrm, yel, real_room(H_ATRIUM(house)) == NOWHERE ? "Nowhere" : world[real_room(H_ATRIUM(house))].name, grn, nrm, cyn, H_EXIT(house) < 0 || H_EXIT(house) >= NUM_OF_DIRS ? -1 : H_EXIT(house), nrm, yel, H_EXIT(house) < 0 || H_EXIT(house) >= NUM_OF_DIRS ? "Nowhere" : dirs[H_EXIT(house)], grn, nrm, cyn, house_types[H_MODE(house)], grn, nrm, cyn, YESNO(H_PRUNE_SAFE(house)), grn, nrm, cyn, H_COST(house), nrm, grn, nrm, cyn, H_MAX_SECURE(house), nrm, grn, nrm, cyn, H_MAX_LOCKED(house), nrm, grn, nrm, grn, nrm, grn, nrm, grn, nrm, grn, nrm ); release_buffer(name); OLC_MODE(d) = HEDIT_MAIN_MENU; }
/* * Block drivers call this function to signal completion of an I/O request. */ void block_request_completed(struct block_device *dev, struct request *req) { req->buf->b_flags |= BUF_UPTODATE; release_buffer(req->buf); buffer_unlock(req->buf); slab_free(request_cachep, req); if (request_queue_empty(dev)) return; req = list_first_entry(&dev->requests, struct request, chain); list_del(&req->chain); dev->handle_request(dev, req); }