• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ISC_BUFFER_VALID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ISC_BUFFER_VALID函数的典型用法代码示例。如果您正苦于以下问题:C++ ISC_BUFFER_VALID函数的具体用法?C++ ISC_BUFFER_VALID怎么用?C++ ISC_BUFFER_VALID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ISC_BUFFER_VALID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: isc_buffer_reallocate

isc_result_t
isc_buffer_reallocate(isc_buffer_t **dynbuffer, unsigned int length) {
	unsigned char *bdata;

	REQUIRE(dynbuffer != NULL);
	REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
	REQUIRE((*dynbuffer)->mctx != NULL);

	if ((*dynbuffer)->length > length)
		return (ISC_R_NOSPACE);

	/*
	 * XXXMUKS: This is far more expensive than plain realloc() as
	 * it doesn't remap pages, but does ordinary copy. So is
	 * isc_mem_reallocate(), which has additional issues.
	 */
	bdata = isc_mem_get((*dynbuffer)->mctx, length);
	if (bdata == NULL)
		return (ISC_R_NOMEMORY);

	memmove(bdata, (*dynbuffer)->base, (*dynbuffer)->length);
	isc_mem_put((*dynbuffer)->mctx, (*dynbuffer)->base,
		    (*dynbuffer)->length);

	(*dynbuffer)->base = bdata;
	(*dynbuffer)->length = length;

	return (ISC_R_SUCCESS);
}
开发者ID:each,项目名称:bind9-collab,代码行数:29,代码来源:buffer.c


示例2: isc_buffer_reserve

isc_result_t
isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size) {
	isc_uint64_t len;

	REQUIRE(dynbuffer != NULL);
	REQUIRE(ISC_BUFFER_VALID(*dynbuffer));

	len = (*dynbuffer)->length;
	if ((len - (*dynbuffer)->used) >= size)
		return (ISC_R_SUCCESS);

	if ((*dynbuffer)->mctx == NULL)
		return (ISC_R_NOSPACE);

	/* Round to nearest buffer size increment */
	len = size + (*dynbuffer)->used;
	len = (len + ISC_BUFFER_INCR - 1 - ((len - 1) % ISC_BUFFER_INCR));

	/* Cap at UINT_MAX */
	if (len > UINT_MAX) {
		len = UINT_MAX;
	}

	if ((len - (*dynbuffer)->used) < size)
		return (ISC_R_NOMEMORY);

	return (isc_buffer_reallocate(dynbuffer, (unsigned int) len));
}
开发者ID:each,项目名称:bind9-collab,代码行数:28,代码来源:buffer.c


示例3: isc_buffer_copyregion

isc_result_t
isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
	unsigned char *base;
	unsigned int available;
	isc_result_t result;

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(r != NULL);

	/*
	 * XXXDCL
	 */
	base = isc_buffer_used(b);
	available = isc_buffer_availablelength(b);
	if (ISC_UNLIKELY(b->autore)) {
		result = isc_buffer_reserve(&b, r->length);
		if (result != ISC_R_SUCCESS)
			return (result);
	}
	if (r->length > available)
		return (ISC_R_NOSPACE);
	memmove(base, r->base, r->length);
	b->used += r->length;

	return (ISC_R_SUCCESS);
}
开发者ID:each,项目名称:bind9-collab,代码行数:26,代码来源:buffer.c


示例4: isc_buffer_allocate

isc_result_t
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
		    unsigned int length)
{
	isc_buffer_t *dbuf;
	unsigned char * bdata;
	REQUIRE(dynbuffer != NULL);
	REQUIRE(*dynbuffer == NULL);

	dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
	if (dbuf == NULL)
		return (ISC_R_NOMEMORY);

	bdata = isc_mem_get(mctx, length);
	if (bdata == NULL) {
		isc_mem_put(mctx, dbuf, sizeof(isc_buffer_t));
		return (ISC_R_NOMEMORY);
	}

	isc_buffer_init(dbuf, bdata, length);
	dbuf->mctx = mctx;

	ENSURE(ISC_BUFFER_VALID(dbuf));

	*dynbuffer = dbuf;

	return (ISC_R_SUCCESS);
}
开发者ID:each,项目名称:bind9-collab,代码行数:28,代码来源:buffer.c


示例5: isc__buffer_putuint32

void
isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val) {
	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->used + 4 <= b->length);

	ISC__BUFFER_PUTUINT32(b, val);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:7,代码来源:buffer.c


示例6: buffer_append_str

/**
 * @pre closure points to a valid isc_buffer
 * @pre isc_buffer has non-NULL mctx
 * @pre isc_buffer has NULL buffer OR a buffer allocated from mctx
 *
 * @post closure contains \0 terminated string which is concatenation
 *       of previous context and input text
 */
static void
buffer_append_str(void *closure, const char *text, int textlen) {
	isc_buffer_t *out_buf = closure;
	isc_region_t new_space;
	isc_region_t old_space;

	REQUIRE(ISC_BUFFER_VALID(out_buf));
	REQUIRE(out_buf->mctx != NULL);
	REQUIRE(text != NULL);

	/* Allocate sufficiently long output buffer. */
	isc_buffer_region(out_buf, &old_space);
	new_space.length = isc_buffer_length(out_buf) + textlen + 1;
	new_space.base = isc_mem_get(out_buf->mctx, new_space.length);
	RUNTIME_CHECK(new_space.base != NULL);
	isc_buffer_reinit(out_buf, new_space.base, new_space.length);
	if (old_space.base != NULL)
		isc_mem_put(out_buf->mctx, old_space.base, old_space.length);

	/* Append output text and \0-terminate it.
	 * Overwrite \0 at the end if needed. */
	if (isc_buffer_usedlength(out_buf) != 0)
		/* Previous string is \0 terminated, chop \0. */
		isc_buffer_subtract(out_buf, 1);
	isc_buffer_putstr(out_buf, text);
	isc_buffer_putuint8(out_buf, '\0');
}
开发者ID:pspacek,项目名称:bind-dyndb-ldap,代码行数:35,代码来源:fwd.c


示例7: isc__buffer_putmem

void
isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
		   unsigned int length)
{
	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->used + length <= b->length);

	ISC__BUFFER_PUTMEM(b, base, length);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:9,代码来源:buffer.c


示例8: isc__buffer_first

void
isc__buffer_first(isc_buffer_t *b) {
	/*
	 * Make the consumed region empty.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));

	ISC__BUFFER_FIRST(b);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:10,代码来源:buffer.c


示例9: isc__buffer_clear

void
isc__buffer_clear(isc_buffer_t *b) {
	/*
	 * Make the used region empty.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));

	ISC__BUFFER_CLEAR(b);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:10,代码来源:buffer.c


示例10: isc__buffer_usedregion

void
isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r) {
	/*
	 * Make 'r' refer to the used region of 'b'.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(r != NULL);

	ISC__BUFFER_USEDREGION(b, r);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例11: isc__buffer_subtract

void
isc__buffer_subtract(isc_buffer_t *b, unsigned int n) {
	/*
	 * Decrease the 'used' region of 'b' by 'n' bytes.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->used >= n);

	ISC__BUFFER_SUBTRACT(b, n);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例12: isc__buffer_add

void
isc__buffer_add(isc_buffer_t *b, unsigned int n) {
	/*
	 * Increase the 'used' region of 'b' by 'n' bytes.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->used + n <= b->length);

	ISC__BUFFER_ADD(b, n);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例13: isc__buffer_back

void
isc__buffer_back(isc_buffer_t *b, unsigned int n) {
	/*
	 * Decrease the 'consumed' region of 'b' by 'n' bytes.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(n <= b->current);

	ISC__BUFFER_BACK(b, n);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例14: isc__buffer_remainingregion

void
isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r) {
	/*
	 * Make 'r' refer to the remaining region of 'b'.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(r != NULL);

	ISC__BUFFER_REMAININGREGION(b, r);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例15: isc__buffer_forward

void
isc__buffer_forward(isc_buffer_t *b, unsigned int n) {
	/*
	 * Increase the 'consumed' region of 'b' by 'n' bytes.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->current + n <= b->used);

	ISC__BUFFER_FORWARD(b, n);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例16: isc__buffer_availableregion

void
isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r) {
	/*
	 * Make 'r' refer to the available region of 'b'.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(r != NULL);

	ISC__BUFFER_AVAILABLEREGION(b, r);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例17: isc__buffer_setactive

void
isc__buffer_setactive(isc_buffer_t *b, unsigned int n) {
	/*
	 * Sets the end of the active region 'n' bytes after current.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(b->current + n <= b->used);

	ISC__BUFFER_SETACTIVE(b, n);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例18: isc__buffer_activeregion

void
isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r) {
	/*
	 * Make 'r' refer to the active region of 'b'.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(r != NULL);

	ISC__BUFFER_ACTIVEREGION(b, r);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:11,代码来源:buffer.c


示例19: isc__buffer_invalidate

void
isc__buffer_invalidate(isc_buffer_t *b) {
	/*
	 * Make 'b' an invalid buffer.
	 */

	REQUIRE(ISC_BUFFER_VALID(b));
	REQUIRE(!ISC_LINK_LINKED(b, link));
	REQUIRE(b->mctx == NULL);

	ISC__BUFFER_INVALIDATE(b);
}
开发者ID:Gradwell,项目名称:bind9,代码行数:12,代码来源:buffer.c


示例20: isc__buffer_putuint32

void
isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val) {
	isc_result_t result;
	REQUIRE(ISC_BUFFER_VALID(b));
	if (ISC_UNLIKELY(b->autore)) {
		result = isc_buffer_reserve(&b, 4);
		REQUIRE(result == ISC_R_SUCCESS);
	}
	REQUIRE(isc_buffer_availablelength(b) >= 4);

	ISC__BUFFER_PUTUINT32(b, val);
}
开发者ID:each,项目名称:bind9-collab,代码行数:12,代码来源:buffer.c



注:本文中的ISC_BUFFER_VALID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ISC_LINK_INIT函数代码示例发布时间:2022-05-30
下一篇:
C++ ISCSI_DBG_TCP函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap