本文整理汇总了C++中release_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ release_buffer函数的具体用法?C++ release_buffer怎么用?C++ release_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了release_buffer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_map
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;[email protected]\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");
}
示例2: find_help_entry
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);
}
示例3: cdfs_find_in_dir
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;
}
示例4: list_wands_staves
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);
}
示例5: release_buffer
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;
}
示例6: list_scrolls_potions
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);
}
示例7: do_list_wear
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);
}
示例8: cdfs_stat
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;
}
示例9: intel_bufferobj_buffer
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;
}
示例10: smtp_from
// ------------------------------------------------
// 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;
}
示例11: cdfs_opendir
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;
}
示例12: read_stderr
/**
* @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;
}
示例13: intel_bufferobj_data
/**
* 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;
}
示例14: intel_bufferobj_subdata
/**
* 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);
}
}
示例15: ping_request
// ------------------------------------------------
// 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);
}