本文整理汇总了C++中check_size函数的典型用法代码示例。如果您正苦于以下问题:C++ check_size函数的具体用法?C++ check_size怎么用?C++ check_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pop_raw
static int
pop_raw (lw6sys_context_t * sys_context, lw6sys_hexa_serializer_t * hexa_serializer, u_int8_t * buf, int size)
{
int ret = 0;
int i;
int j;
char hexa2[3] = { 0, 0, 0 }; // third 0 is *very* important
if (check_size (sys_context, hexa_serializer, size * 2))
{
for (i = 0; i < size; ++i, hexa_serializer->pos += 2)
{
j = 0;
memcpy (hexa2, hexa_serializer->buf + hexa_serializer->pos, 2);
/*
* Performing sscanf on long strings is a performance killer
* for sscanf calls strlen internally to get the length
* of the string...
*/
sscanf (hexa2, "%02x", &j);
buf[i] = (u_int8_t) j;
}
if (hexa_serializer->pos < hexa_serializer->buf_size && !(hexa_serializer->pos & 0x01))
{
ret = 1;
}
else
{
lw6sys_log (sys_context, LW6SYS_LOG_WARNING,
_x_ ("inconsistent hexa_serializer after pop, pos=%d, buf_size=%d"), hexa_serializer->pos, hexa_serializer->buf_size);
}
}
return ret;
}
开发者ID:lijiaqigreat,项目名称:liquidwar-web,代码行数:35,代码来源:sys-hexa.c
示例2: check_tab
void check_tab(char **tab)
{
if (check_char(tab) == 1)
put_err("One character is not * or X");
if (check_size(tab) == 1)
put_err("The lab is not a rectangle");
}
开发者ID:Cmdeew,项目名称:dante,代码行数:7,代码来源:error.c
示例3: check_size
vector& operator=(const Src& that)
{
check_size(size(that));
for (int i= 0; i < my_size; ++i)
data[i]= that[i];
return *this;
}
开发者ID:2075,项目名称:discovering_modern_cpp,代码行数:7,代码来源:vector_noexcept.cpp
示例4: resize
static int
resize (lw6sys_context_t * sys_context, lw6sys_hexa_serializer_t * hexa_serializer, int required)
{
int ret = 0;
int new_size = 0;
if (!check_size (sys_context, hexa_serializer, required))
{
new_size = (hexa_serializer->buf_size * RESIZE_FACTOR) + RESIZE_PLUS + required;
hexa_serializer->buf = LW6SYS_REALLOC (sys_context, hexa_serializer->buf, new_size);
if (hexa_serializer->buf)
{
hexa_serializer->buf_size = new_size;
ret = 1;
}
else
{
lw6sys_log (sys_context, LW6SYS_LOG_WARNING, _x_ ("can't resize hexa_serializer (new_size=%d), expect serious trouble"), new_size);
}
}
else
{
// nothing to do...
ret = 1;
}
return ret;
}
开发者ID:lijiaqigreat,项目名称:liquidwar-web,代码行数:28,代码来源:sys-hexa.c
示例5: test_mknod
static int test_mknod(void)
{
int err = 0;
int res;
start_test("mknod");
unlink(testfile);
res = mknod(testfile, 0644, 0);
if (res == -1) {
PERROR("mknod");
return -1;
}
res = check_type(testfile, S_IFREG);
if (res == -1)
return -1;
err += check_mode(testfile, 0644);
err += check_nlink(testfile, 1);
err += check_size(testfile, 0);
res = unlink(testfile);
if (res == -1) {
PERROR("unlink");
return -1;
}
res = check_nonexist(testfile);
if (res == -1)
return -1;
if (err)
return -1;
success();
return 0;
}
开发者ID:quobert,项目名称:libfuse,代码行数:32,代码来源:test.c
示例6: strtab_read
static int strtab_read(const struct buffer *in, struct parsed_elf *pelf)
{
Elf64_Ehdr *ehdr;
Elf64_Word i;
ehdr = &pelf->ehdr;
if (ehdr->e_shstrndx >= ehdr->e_shnum) {
ERROR("Section header string table index out of range: %d\n",
ehdr->e_shstrndx);
return -1;
}
/* For each section of type SHT_STRTAB create a symtab buffer. */
pelf->strtabs = calloc(ehdr->e_shnum, sizeof(struct buffer *));
for (i = 0; i < ehdr->e_shnum; i++) {
struct buffer *b;
Elf64_Shdr *shdr = &pelf->shdr[i];
if (shdr->sh_type != SHT_STRTAB)
continue;
b = calloc(1, sizeof(*b));
buffer_splice(b, in, shdr->sh_offset, shdr->sh_size);
if (check_size(in, shdr->sh_offset, buffer_size(b), "strtab")) {
ERROR("STRTAB section not within bounds: %d\n", i);
free(b);
return -1;
}
pelf->strtabs[i] = b;
}
return 0;
}
开发者ID:RafaelRMachado,项目名称:Coreboot,代码行数:35,代码来源:elfheaders.c
示例7: shdr_read
static int
shdr_read(const struct buffer *in, struct parsed_elf *pelf,
struct xdr *xdr, int bit64)
{
struct buffer b;
Elf64_Shdr *shdr;
Elf64_Ehdr *ehdr;
int i;
ehdr = &pelf->ehdr;
/* cons up an input buffer for the section headers.
* Note that the section headers can be anywhere,
* per the ELF spec, You'd be surprised how many ELF
* readers miss this little detail.
*/
buffer_splice(&b, in, ehdr->e_shoff, ehdr->e_shentsize * ehdr->e_shnum);
if (check_size(in, ehdr->e_shoff, buffer_size(&b), "section headers"))
return -1;
/* gather up all the shdrs. */
shdr = calloc(ehdr->e_shnum, sizeof(*shdr));
for (i = 0; i < ehdr->e_shnum; i++) {
DEBUG("Parsing section %d\n", i);
elf_shdr(&b, &shdr[i], ehdr->e_shentsize, xdr, bit64);
}
pelf->shdr = shdr;
return 0;
}
开发者ID:RafaelRMachado,项目名称:Coreboot,代码行数:31,代码来源:elfheaders.c
示例8: init_legacy_currval
static void init_legacy_currval(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
struct gl_client_array *arrays = vbo->legacy_currval;
GLuint i;
memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_MAX);
/* Set up a constant (StrideB == 0) array for each current
* attribute:
*/
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
struct gl_client_array *cl = &arrays[i];
/* Size will have to be determined at runtime:
*/
cl->Size = check_size(ctx->Current.Attrib[i]);
cl->Stride = 0;
cl->StrideB = 0;
cl->Enabled = 1;
cl->Type = GL_FLOAT;
cl->Ptr = (const void *)ctx->Current.Attrib[i];
cl->_ElementSize = cl->Size * sizeof(GLfloat);
_mesa_reference_buffer_object(ctx, &cl->BufferObj,
ctx->Shared->NullBufferObj);
}
}
开发者ID:GYGit,项目名称:reactos,代码行数:27,代码来源:vbo_context.c
示例9: norecurse_32
/* Convert a number to a certain radix and send over uart.
* 32-bit version */
static void norecurse_32(uint32_t input, uint8_t radix)
{
uint8_t remainder = input % radix;
uint8_t *p = charbuff;
buffsize = 0;
if(input == 0)
charbuff[buffsize++] = '0';
while(input >= radix) {
if(remainder <= 9)
*p++ = remainder + '0';
else
*p++ = remainder - 10 + 'A';
buffsize++;
input /= radix;
remainder = input % radix;
}
if(remainder > 0) {
if(remainder <= 9)
*p++ = remainder + '0';
else
*p++ = remainder - 10 + 'A';
buffsize++;
}
// Calculate amount we still need to pad. We never truncate a result.
if(fieldwidth > buffsize)
fieldwidth -= buffsize;
else
fieldwidth = 0;
while(fieldwidth--) {
printf_packet.data[printf_packet.size++] = padchar;
check_size();
}
while(buffsize > 0) {
buffsize--;
printf_packet.data[printf_packet.size++] = charbuff[buffsize];
check_size();
}
}
开发者ID:135u5,项目名称:dynamiclinker,代码行数:49,代码来源:printf.c
示例10: check_size
vector operator+( const vector& that ) const
{
check_size(that.my_size);
vector sum(my_size);
for (unsigned i= 0; i < my_size; ++i)
sum[i] = data[i] + that[i];
return sum ;
}
开发者ID:2075,项目名称:discovering_modern_cpp,代码行数:8,代码来源:vector_features.cpp
示例11: DiagramCanvas
SubjectCanvas::SubjectCanvas(UmlCanvas * canvas, int x, int y, int id)
: DiagramCanvas(0, canvas, x, y, SUBJECT_CANVAS_MIN_SIZE,
SUBJECT_CANVAS_MIN_SIZE, id) {
browser_node = canvas->browser_diagram();
itscolor = UmlDefaultColor;
check_size();
connect(DrawingSettings::instance(), SIGNAL(changed()), this, SLOT(modified()));
}
开发者ID:SciBoy,项目名称:douml,代码行数:8,代码来源:SubjectCanvas.cpp
示例12: SIPBytes_FromStringAndSize
/*
* Implement sequence item sub-script for the type.
*/
static PyObject *sipVoidPtr_item(PyObject *self, SIP_SSIZE_T idx)
{
if (check_size(self) < 0 || check_index(self, idx) < 0)
return NULL;
return SIPBytes_FromStringAndSize(
(char *)((sipVoidPtrObject *)self)->voidptr + idx, 1);
}
开发者ID:Werkov,项目名称:SIP,代码行数:11,代码来源:voidptr.c
示例13: hide
void SubjectCanvas::modified() {
// force son reaffichage
hide();
check_size();
show();
canvas()->update();
package_modified();
}
开发者ID:SciBoy,项目名称:douml,代码行数:8,代码来源:SubjectCanvas.cpp
示例14: test_link2
static int test_link2(void)
{
const char *data = testdata;
int datalen = testdatalen;
int err = 0;
int res;
start_test("link-unlink-link");
res = create_file(testfile, data, datalen);
if (res == -1)
return -1;
unlink(testfile2);
res = link(testfile, testfile2);
if (res == -1) {
PERROR("link");
return -1;
}
res = unlink(testfile);
if (res == -1) {
PERROR("unlink");
return -1;
}
res = check_nonexist(testfile);
if (res == -1)
return -1;
res = link(testfile2, testfile);
if (res == -1) {
PERROR("link");
}
res = check_type(testfile, S_IFREG);
if (res == -1)
return -1;
err += check_mode(testfile, 0644);
err += check_nlink(testfile, 2);
err += check_size(testfile, datalen);
err += check_data(testfile, data, 0, datalen);
res = unlink(testfile2);
if (res == -1) {
PERROR("unlink");
return -1;
}
err += check_nlink(testfile, 1);
res = unlink(testfile);
if (res == -1) {
PERROR("unlink");
return -1;
}
res = check_nonexist(testfile);
if (res == -1)
return -1;
if (err)
return -1;
success();
return 0;
}
开发者ID:daddy366,项目名称:anarchy-fuse,代码行数:58,代码来源:test.c
示例15: main
int main(int argc, char *argv[])
{
char out_put[100] = "";
if(argc != 7)
{
strcat(out_put, "error\n");
printf("%s", out_put);
return 0;
}
else
{
int i;
int j;
int64_t p[6];
char* error;
for(i = 1; i < 7; i = i + 1)
{
p[i-1] = strtol(argv[i], &error, 10);
if (*error != '\0')
{
strcat(out_put, "error\n");
printf("%s", out_put);
return 0;
}
}
int64_t sides[3];
sides[0] = length(p[0], p[1], p[2], p[3]);
sides[1] = length(p[2], p[3], p[4], p[5]);
sides[2] = length(p[4], p[5], p[0], p[1]);
if(colin_test(p[0], p[1], p[2], p[3], p[4], p[5]))
{
strcat(out_put, "not a triangle");
printf("%s", out_put);
return 0;
}
for(i = 0; i < 3; i = i + 1)
{
if(sides[i] == 0)
{
strcat(out_put, "not a triangle");
printf("%s", out_put);
return 0;
}
}
strcat(out_put, check_size(sides));
strcat(out_put, check_angle(sides));
printf("%s\n", out_put);
return 0;
}
}
开发者ID:heidariank,项目名称:cs5959-f15-shared,代码行数:57,代码来源:triangle.c
示例16: write
bool Buffer::write(const void *data, uint32_t len) {
if (!check_size(wptr + len)) {
memcpy(bptr + wptr, data, len);
wptr += len;
return true;
}
error = true;
return false;
}
开发者ID:FlankerZ,项目名称:collabREate,代码行数:9,代码来源:buffer.cpp
示例17: check_all
void check_all(void)
{
uint8_t size;
for( size =1; size < 255; size++ )
{
printf("size=%d\n", size);
check_size(size);
}
}
开发者ID:benhaha,项目名称:u8glib,代码行数:9,代码来源:intersection.c
示例18: v4l1_compat_get_capabilities
static noinline int v4l1_compat_get_capabilities(
struct video_capability *cap,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_framebuffer fbuf;
struct v4l2_capability *cap2;
cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL);
if (!cap2) {
err = -ENOMEM;
return err;
}
memset(cap, 0, sizeof(*cap));
memset(&fbuf, 0, sizeof(fbuf));
err = drv(inode, file, VIDIOC_QUERYCAP, cap2);
if (err < 0) {
dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err);
goto done;
}
if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) {
err = drv(inode, file, VIDIOC_G_FBUF, &fbuf);
if (err < 0) {
dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err);
memset(&fbuf, 0, sizeof(fbuf));
}
err = 0;
}
memcpy(cap->name, cap2->card,
min(sizeof(cap->name), sizeof(cap2->card)));
cap->name[sizeof(cap->name) - 1] = 0;
if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE)
cap->type |= VID_TYPE_CAPTURE;
if (cap2->capabilities & V4L2_CAP_TUNER)
cap->type |= VID_TYPE_TUNER;
if (cap2->capabilities & V4L2_CAP_VBI_CAPTURE)
cap->type |= VID_TYPE_TELETEXT;
if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY)
cap->type |= VID_TYPE_OVERLAY;
if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING)
cap->type |= VID_TYPE_CLIPPING;
cap->channels = count_inputs(inode, file, drv);
check_size(inode, file, drv,
&cap->maxwidth, &cap->maxheight);
cap->audios = 0; /* FIXME */
cap->minwidth = 48; /* FIXME */
cap->minheight = 32; /* FIXME */
done:
kfree(cap2);
return err;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:57,代码来源:v4l1-compat.c
示例19: check_size
double MedianStats::median() {
check_size(1);
std::sort(values_.begin(), values_.end());
size_t n {values_.size()};
if (n % 2 == 0)
return (values_[n/2 - 1] + values_[n/2])/2.0;
else
return values_[n/2];
}
开发者ID:gjbex,项目名称:training-material,代码行数:9,代码来源:median_stats.cpp
示例20: pop_uint32
std::string unpacker::pop_string() {
uint32_t length = pop_uint32();
check_size(length, position_);
std::string s = std::string(buffer_ + position_, length);
position_ = static_cast<uint32_t>(position_ + length);
return s;
}
开发者ID:tyronelau,项目名称:sandbox,代码行数:9,代码来源:packer.cpp
注:本文中的check_size函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论