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

C++ CHECK_SIZE函数代码示例

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

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



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

示例1: main

int
main(void)
{
	int res = 0;
#if !defined __uint128_t_defined
	typedef struct {
		uint64_t l;
		uint64_t h;
	} uint128_t;
#define __uint128_t_defined
#endif	/* !uint128_t */

#define CHECK_SIZE(x, y)						\
	if (sizeof(x) != sizeof(y)) {					\
		fprintf(						\
			stderr,						\
			"sizeof(" #x ") -> %zu\t"			\
			"sizeof(" #y ") -> %zu\n",			\
			sizeof(x), sizeof(y));				\
		res = 1;						\
	}

	CHECK_SIZE(struct dt_dt_s, uint128_t);
	CHECK_SIZE(struct dt_d_s, uint64_t);
	CHECK_SIZE(struct dt_t_s, uint64_t);
	CHECK_SIZE(dt_ymdhms_t, uint64_t);
	CHECK_SIZE(dt_sexy_t, uint64_t);
	return res;
}
开发者ID:aborruso,项目名称:dateutils,代码行数:29,代码来源:struct-7.c


示例2: nodeset_expandtofit

static bool nodeset_expandtofit (nodeset_t *n, uint32_t r)
{
    uint32_t size = NS_SIZE (n);
    while (size <= r && CHECK_SIZE(size, size << 1))
        size = size << 1;
    while (size <= r && CHECK_SIZE(size, size + veb_minsize))
        size += veb_minsize;
    if (size <= r && CHECK_SIZE(size, r + 1))
        size = r + 1;
    if (size <= r)
        return false;
    return nodeset_resize (n, size);
}
开发者ID:surajpkn,项目名称:flux-core,代码行数:13,代码来源:nodeset.c


示例3: anoubisd_msg_authverify_size

static int
anoubisd_msg_authverify_size(const char *buf, int buflen)
{
	DECLARE_SIZE();
	struct anoubisd_msg_authverify		*verify;

	CAST(verify, buf, buflen);
	SHIFT_FIELD(verify, payload, buf, buflen);
	CHECK_SIZE(verify->datalen);
	CHECK_SIZE(verify->siglen);
	SHIFT_CNT(verify->datalen, buf, buflen);
	SHIFT_CNT(verify->siglen, buf, buflen);

	RETURN_SIZE();
}
开发者ID:genua,项目名称:anoubis,代码行数:15,代码来源:amsg_verify.c


示例4: anoubisd_msg_authchallenge_size

static int
anoubisd_msg_authchallenge_size(const char *buf, int buflen)
{
	DECLARE_SIZE();
	struct anoubisd_msg_authchallenge	*challenge;

	CAST(challenge, buf, buflen);
	SHIFT_FIELD(challenge, payload, buf, buflen);
	CHECK_SIZE(challenge->challengelen);
	CHECK_SIZE(challenge->idlen);
	SHIFT_CNT(challenge->challengelen, buf, buflen);
	SHIFT_CNT(challenge->idlen, buf, buflen);

	RETURN_SIZE();
}
开发者ID:genua,项目名称:anoubis,代码行数:15,代码来源:amsg_verify.c


示例5: test_unref_reparent

static bool test_unref_reparent(void)
{
	void *root, *p1, *p2, *c1;

	printf("test: unref_reparent\n# UNREFERENCE AFTER PARENT FREED\n");

	root = talloc_named_const(NULL, 0, "root");
	p1 = talloc_named_const(root, 1, "orig parent");
	p2 = talloc_named_const(root, 1, "parent by reference");

	c1 = talloc_named_const(p1, 1, "child");
	talloc_reference(p2, c1);

	CHECK_PARENT("unref_reparent", c1, p1);

	talloc_free(p1);

	CHECK_PARENT("unref_reparent", c1, p2);

	talloc_unlink(p2, c1);

	CHECK_SIZE("unref_reparent", root, 1);

	talloc_free(p2);
	talloc_free(root);

	printf("success: unref_reparent\n");
	return true;
}
开发者ID:urisimchoni,项目名称:samba,代码行数:29,代码来源:testsuite.c


示例6: CHECK_ATOMS

// fall(linethickness)
static Box *fall(ListBox *args)
{
    CHECK_ATOMS(args);
    CHECK_SIZE(args);

    return new FallBox((*args)[0]->size(X));
}
开发者ID:aidanfarrow,项目名称:GC_tidy,代码行数:8,代码来源:VSLBuiltin.C


示例7: str_buf_append

void str_buf_append( str_buf_t *buf, const char *str )
{
  int len = strlen( str );
  CHECK_SIZE( buf, len );
  memcpy( buf->data + buf->data_len, str, len );
  buf->data_len += len;
}
开发者ID:TheProjecter,项目名称:jxtl,代码行数:7,代码来源:str_buf.c


示例8: test_ref3

/*
  test references 
*/
static bool test_ref3(void)
{
	void *root, *p1, *p2, *ref, *r1;

	printf("test: ref3 [\nPARENT REFERENCE FREE\n]\n");

	root = talloc_named_const(NULL, 0, "root");
	p1 = talloc_named_const(root, 1, "p1");
	p2 = talloc_named_const(root, 1, "p2");
	r1 = talloc_named_const(p1, 1, "r1");
	ref = talloc_reference(p2, r1);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref3", p1, 2);
	CHECK_BLOCKS("ref3", p2, 2);
	CHECK_BLOCKS("ref3", r1, 1);

	fprintf(stderr, "Freeing p1\n");
	talloc_free(p1);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref3", p2, 2);
	CHECK_BLOCKS("ref3", r1, 1);

	fprintf(stderr, "Freeing p2\n");
	talloc_free(p2);
	talloc_report_full(root, stderr);

	CHECK_SIZE("ref3", root, 0);

	talloc_free(root);

	printf("success: ref3\n");
	return true;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:38,代码来源:testsuite.c


示例9: attribute_names

void
WRATHDefaultTextAttributePacker::
attribute_names(std::vector<std::string> &out_names, int number_custom_data) const
{
  CHECK_SIZE(0);
  CHECK_SIZE(1);
  CHECK_SIZE(2);
  CHECK_SIZE(3);
  CHECK_SIZE(4);
  CHECK_SIZE(5);
  CHECK_SIZE(6);

  unsigned int N, R;

  N=number_custom_data/4;
  R=number_custom_data%4;
  if(R>0) 
    {
      ++N;
    }
  
  out_names.resize(packer_attribute_names().size()+N);
  std::copy(packer_attribute_names().begin(),
            packer_attribute_names().end(),
            out_names.begin());
  for(unsigned int i=0, k=packer_attribute_names().size(); i<N; ++i, ++k)
    {
      std::ostringstream ostr;
      ostr << "custom_data" << i;
      out_names[k]=ostr.str();
    }
}
开发者ID:nomovok-opensource,项目名称:wrath,代码行数:32,代码来源:WRATHDefaultTextAttributePacker.cpp


示例10: main

int
main(void)
{
	int res = 0;

#define CHECK_SIZE(x, y)						\
	if (sizeof(x) != sizeof(y)) {					\
		fprintf(stderr, "sizeof(" #x ") -> %zu\n", sizeof(x));	\
		res = 1;						\
	}

	CHECK_SIZE(struct dt_d_s, uint64_t);
	CHECK_SIZE(dt_ymd_t, uint32_t);
	CHECK_SIZE(dt_ymcw_t, uint32_t);
	CHECK_SIZE(dt_bizda_t, uint32_t);
	CHECK_SIZE(dt_md_t, uint32_t);
	CHECK_SIZE(dt_daisy_t, uint32_t);
	return res;
}
开发者ID:cffyh,项目名称:dateutils,代码行数:19,代码来源:struct-8.c


示例11: test_ref1

/*
  test references 
*/
static bool test_ref1(void)
{
	void *root, *p1, *p2, *ref, *r1;

	printf("test: ref1\n# SINGLE REFERENCE FREE\n");

	root = talloc_named_const(NULL, 0, "root");
	p1 = talloc_named_const(root, 1, "p1");
	p2 = talloc_named_const(p1, 1, "p2");
	talloc_named_const(p1, 1, "x1");
	talloc_named_const(p1, 2, "x2");
	talloc_named_const(p1, 3, "x3");

	r1 = talloc_named_const(root, 1, "r1");	
	ref = talloc_reference(r1, p2);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref1", p1, 5);
	CHECK_BLOCKS("ref1", p2, 1);
	CHECK_BLOCKS("ref1", ref, 1);
	CHECK_BLOCKS("ref1", r1, 2);

	fprintf(stderr, "Freeing p2\n");
	talloc_unlink(r1, p2);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref1", p1, 5);
	CHECK_BLOCKS("ref1", p2, 1);
	CHECK_BLOCKS("ref1", r1, 1);

	fprintf(stderr, "Freeing p1\n");
	talloc_free(p1);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref1", r1, 1);

	fprintf(stderr, "Freeing r1\n");
	talloc_free(r1);
	talloc_report_full(NULL, stderr);

	fprintf(stderr, "Testing NULL\n");
	if (talloc_reference(root, NULL)) {
		return false;
	}

	CHECK_BLOCKS("ref1", root, 1);

	CHECK_SIZE("ref1", root, 0);

	talloc_free(root);
	printf("success: ref1\n");
	return true;
}
开发者ID:urisimchoni,项目名称:samba,代码行数:56,代码来源:testsuite.c


示例12: XvdiGetVideo

int
XvdiGetVideo(
   ClientPtr client,
   DrawablePtr pDraw,
   XvPortPtr pPort,
   GCPtr pGC,
   INT16 vid_x, INT16 vid_y, 
   CARD16 vid_w, CARD16 vid_h, 
   INT16 drw_x, INT16 drw_y,
   CARD16 drw_w, CARD16 drw_h
){
  DrawablePtr pOldDraw;

  CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);

  /* UPDATE TIME VARIABLES FOR USE IN EVENTS */

  UpdateCurrentTime();

  /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
     INFORM CLIENT OF ITS FAILURE */

  if (pPort->grab.client && (pPort->grab.client != client))
    {
      XvdiSendVideoNotify(pPort, pDraw, XvBusy);
      return Success;
    }

  /* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
     EVENTS TO ANY CLIENTS WHO WANT THEM */

  pOldDraw = pPort->pDraw;
  if ((pOldDraw) && (pOldDraw != pDraw))
    {
      XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
    }

  (void) (* pPort->pAdaptor->ddGetVideo)(client, pDraw, pPort, pGC,
					   vid_x, vid_y, vid_w, vid_h, 
					   drw_x, drw_y, drw_w, drw_h);

  if ((pPort->pDraw) && (pOldDraw != pDraw))
    {
      pPort->client = client;
      XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
    }

  pPort->time = currentTime;

  return (Success);

}
开发者ID:JoliOS,项目名称:xorg-server,代码行数:52,代码来源:xvmain.c


示例13: METHOD

METHOD(array, Binary_encode, KeyPair)
{
    CHECK_SIZE(args, 2);
    CHECK_TYPE(args.ptr[0], MSGPACK_OBJECT_BIN);
    CHECK_TYPE(args.ptr[1], MSGPACK_OBJECT_BIN);

    msgpack_object_bin secret_key = args.ptr[0].via.bin;
    msgpack_object_bin public_key = args.ptr[1].via.bin;

    CHECK_SIZE(secret_key, 32);
    CHECK_SIZE(public_key, 32);

    SUCCESS {
        uint8_t data[64];
        memcpy(data, secret_key.ptr, 32);
        memcpy(data + 32, public_key.ptr, 32);
        msgpack_pack_bin(res, 64);
        msgpack_pack_bin_body(res, data, 64);
    }

    return 0;
}
开发者ID:Mikhael-Danilov,项目名称:toxcore,代码行数:22,代码来源:binary_encode.c


示例14: test_ref2

/*
  test references 
*/
static bool test_ref2(void)
{
	void *root, *p1, *p2, *ref, *r1;

	printf("test: ref2\n# DOUBLE REFERENCE FREE\n");
	root = talloc_named_const(NULL, 0, "root");
	p1 = talloc_named_const(root, 1, "p1");
	talloc_named_const(p1, 1, "x1");
	talloc_named_const(p1, 1, "x2");
	talloc_named_const(p1, 1, "x3");
	p2 = talloc_named_const(p1, 1, "p2");

	r1 = talloc_named_const(root, 1, "r1");	
	ref = talloc_reference(r1, p2);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref2", p1, 5);
	CHECK_BLOCKS("ref2", p2, 1);
	CHECK_BLOCKS("ref2", r1, 2);

	fprintf(stderr, "Freeing ref\n");
	talloc_unlink(r1, ref);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref2", p1, 5);
	CHECK_BLOCKS("ref2", p2, 1);
	CHECK_BLOCKS("ref2", r1, 1);

	fprintf(stderr, "Freeing p2\n");
	talloc_free(p2);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref2", p1, 4);
	CHECK_BLOCKS("ref2", r1, 1);

	fprintf(stderr, "Freeing p1\n");
	talloc_free(p1);
	talloc_report_full(root, stderr);

	CHECK_BLOCKS("ref2", r1, 1);

	fprintf(stderr, "Freeing r1\n");
	talloc_free(r1);
	talloc_report_full(root, stderr);

	CHECK_SIZE("ref2", root, 0);

	talloc_free(root);
	printf("success: ref2\n");
	return true;
}
开发者ID:urisimchoni,项目名称:samba,代码行数:54,代码来源:testsuite.c


示例15: test_steal

/*
  test steal
*/
static bool test_steal(void)
{
	void *root, *p1, *p2;

	printf("test: steal\n# STEAL\n");

	root = talloc_new(NULL);

	p1 = talloc_array(root, char, 10);
	CHECK_SIZE("steal", p1, 10);

	p2 = talloc_realloc(root, NULL, char, 20);
	CHECK_SIZE("steal", p1, 10);
	CHECK_SIZE("steal", root, 30);

	torture_assert("steal", talloc_steal(p1, NULL) == NULL,
		"failed: stealing NULL should give NULL\n");

	torture_assert("steal", talloc_steal(p1, p1) == p1,
		"failed: stealing to ourselves is a nop\n");
	CHECK_BLOCKS("steal", root, 3);
	CHECK_SIZE("steal", root, 30);

	talloc_steal(NULL, p1);
	talloc_steal(NULL, p2);
	CHECK_BLOCKS("steal", root, 1);
	CHECK_SIZE("steal", root, 0);

	talloc_free(p1);
	talloc_steal(root, p2);
	CHECK_BLOCKS("steal", root, 2);
	CHECK_SIZE("steal", root, 20);
	
	talloc_free(p2);

	CHECK_BLOCKS("steal", root, 1);
	CHECK_SIZE("steal", root, 0);

	talloc_free(root);

	p1 = talloc_size(NULL, 3);
	talloc_report_full(NULL, stderr);
	CHECK_SIZE("steal", NULL, 3);
	talloc_free(p1);

	printf("success: steal\n");
	return true;
}
开发者ID:urisimchoni,项目名称:samba,代码行数:51,代码来源:testsuite.c


示例16: test_realloc_fn

/*
  test talloc_realloc_fn
*/
static bool test_realloc_fn(void)
{
	void *root, *p1;

	printf("test: realloc_fn\n# talloc_realloc_fn\n");

	root = talloc_new(NULL);

	p1 = talloc_realloc_fn(root, NULL, 10);
	CHECK_BLOCKS("realloc_fn", root, 2);
	CHECK_SIZE("realloc_fn", root, 10);
	p1 = talloc_realloc_fn(root, p1, 20);
	CHECK_BLOCKS("realloc_fn", root, 2);
	CHECK_SIZE("realloc_fn", root, 20);
	p1 = talloc_realloc_fn(root, p1, 0);
	CHECK_BLOCKS("realloc_fn", root, 1);
	CHECK_SIZE("realloc_fn", root, 0);

	talloc_free(root);

	printf("success: realloc_fn\n");
	return true;
}
开发者ID:urisimchoni,项目名称:samba,代码行数:26,代码来源:testsuite.c


示例17: anoubisd_msg_eventask_size

static int
anoubisd_msg_eventask_size(const char *buf, int buflen)
{
	struct anoubisd_msg_eventask	*msg;
	struct buf_offset		 offs[5];
	int				 i, j, total = 0;
	DECLARE_SIZE();

	CAST(msg, buf, buflen);

	/* Detect offset overlaps */
	ADDOFFSET(0, csum);
	ADDOFFSET(1, path);
	ADDOFFSET(2, ctxcsum);
	ADDOFFSET(3, ctxpath);
	ADDOFFSET(4, ev);

	for (i=0; i<5; ++i) {
		int	s1, e1;
		if (offs[i].len == 0)
			continue;
		s1 = offs[i].off;
		e1 = s1 + offs[i].len;
		if (e1 > total)
			total = e1;
		for (j=0; j<i; ++j) {
			int	s2, e2;
			if (offs[j].len == 0)
				continue;
			s2 = offs[j].off;
			e2 = s2 + offs[j].len;
			if (s2 < e1 && s1 < e2)
				return -1;
		}
	}

	SHIFT_FIELD(msg, payload, buf, buflen);
	if (total > buflen)
		return -1;
	ADD_SIZE(total);
	if (msg->pathlen)
		CHECK_STRING(buf+msg->pathoff, msg->pathlen);
	if (msg->ctxpathlen)
		CHECK_STRING(buf+msg->ctxpathoff, msg->ctxpathlen);
	if (msg->evlen) {
		int	size = eventdev_hdr_size(buf+msg->evoff, msg->evlen);
		CHECK_SIZE(size);
	}
	RETURN_SIZE();
}
开发者ID:genua,项目名称:anoubis,代码行数:50,代码来源:amsg_verify.c


示例18: padding_extra

    status_t
    BackupDataReader::skip_padding() {
        ssize_t amt;
        ssize_t paddingSize;

        paddingSize = padding_extra(m_pos);
        if (paddingSize > 0) {
            uint32_t padding;
            amt = read(m_fd, &padding, paddingSize);
            CHECK_SIZE(amt, paddingSize);
            m_pos += amt;
        }
        return NO_ERROR;
    }
开发者ID:tranleduy2000,项目名称:aapt_android,代码行数:14,代码来源:BackupData.cpp


示例19: stream_put

/* Copy to source to stream. */
void
stream_put (struct stream *s, void *src, size_t size)
{

  CHECK_SIZE(s, size);

  if (src)
    memcpy (s->data + s->putp, src, size);
  else
    memset (s->data + s->putp, 0, size);

  s->putp += size;
  if (s->putp > s->endp)
    s->endp = s->putp;
}
开发者ID:antonywcl,项目名称:AR-5315u_PLD,代码行数:16,代码来源:stream.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ CHECK_SOME函数代码示例发布时间:2022-05-30
下一篇:
C++ CHECK_RETVAL函数代码示例发布时间: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