当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_SIZE函数代码示例

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


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


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