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

C++ seterr函数代码示例

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

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



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

示例1: gcgcef_msize

/*
 * Extension: report memory size
 */
size_t
gcgcef_msize(CGCEf *cgcef, CGCEf_Type type, size_t count, unsigned ver) {
    size_t n;

    if (cgcef) {
	if (cgcef->e_kind != CGCEF_K_CGCEF) {
	    seterr(ERROR_NOTCGCEF);
	}
	else if (!valid_class(cgcef->e_class)) {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	else if (!valid_version(ver)) {
	    seterr(ERROR_UNKNOWN_VERSION);
	}
	else if (!valid_type(type)) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else if (!(n = _msize(cgcef->e_class, ver, type))) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else {
	    return count * n;
	}
    }
    return 0;
}
开发者ID:BitK-,项目名称:libcgcef,代码行数:29,代码来源:32.fsize.c


示例2: ib

int TSolver::checkexpr()
{int i,j;
 int SL=strlen(S);
 if (SL==1)
   if (!(isconst(S[0])||isnumc(S[0])) )
     {seterr(E_EXPR);
      return 0;
     }
   else return 1;
 if (!(isnumc(S[SL-1])||S[SL-1]==')'||S[SL-1]==']'||isconst(S[SL-1])))
   {seterr(E_EXPR);
    return 0;
   }
#define ib(x) (i>0?(x):1)
 for (i=0;i<SL-1;i++)
   {if (isfn(S[i])||isconst(S[i])||issymbevul(S[i])||S[i]=='('||S[i]=='[')
    if(!( ( isfn(S[i]) && (S[i+1]=='(') )||
          ( i>0?S[i]=='(' && isfn(S[i-1]):1 )||
          ( isconst(S[i]) && (issymbevul(S[i+1])||S[i+1]==')'||S[i+1]==']') )||
          ( ((issymbevul(S[i])||S[i]=='('||S[i]=='[')&&(isnumc(S[i+1])||S[i+1]=='-'||S[i+1]=='_'||isstrevul(S[i+1])||S[i+1]=='('||S[i+1]=='[')) )
         )
      )
      {seterr(E_EXPR);
       return 0;
      }
   }
 return 1;
}
开发者ID:chemikadze,项目名称:oldschool,代码行数:28,代码来源:NPS.CPP


示例3: initiebucks

/*
 * initialize the external bucket sorting data structures
 */
static IEBucks*
initiebucks(Part *part, int bits, uint32_t size)
{
	IEBucks *ib;
	int i;

	ib = MKZ(IEBucks);
	if(ib == nil){
		seterr(EOk, "out of memory");
		return nil;
	}
	ib->bits = bits;
	ib->nbucks = 1 << bits;
	ib->size = size;
	ib->usable = (size - U32Size) / IEntrySize * IEntrySize;
	ib->bucks = MKNZ(IEBuck, ib->nbucks);
	if(ib->bucks == nil){
		seterr(EOk, "out of memory allocation sorting buckets");
		freeiebucks(ib);
		return nil;
	}
	ib->xbuf = MKN(uint8_t, size * ((1 << bits)+1));
	ib->buf = (uint8_t*)(((uintptr)ib->xbuf+size-1)&~(uintptr)(size-1));
	if(ib->buf == nil){
		seterr(EOk, "out of memory allocating sorting buckets' buffers");
		freeiebucks(ib);
		return nil;
	}
	for(i = 0; i < ib->nbucks; i++){
		ib->bucks[i].head = TWID32;
		ib->bucks[i].buf = &ib->buf[i * size];
	}
	ib->part = part;
	return ib;
}
开发者ID:aahud,项目名称:harvey,代码行数:38,代码来源:sortientry.c


示例4: gelf_getphdr

GElf_Phdr*
gelf_getphdr(Elf *elf, int ndx, GElf_Phdr *dst) {
    GElf_Phdr buf;
    char *tmp;
    size_t n;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    tmp = _elf_getphdr(elf, elf->e_class);
    if (!tmp) {
	return NULL;
    }
    if (ndx < 0 || ndx >= elf->e_phnum) {
	seterr(ERROR_BADINDEX);
	return NULL;
    }
    n = _msize(elf->e_class, _elf_version, ELF_T_PHDR);
    if (n == 0) {
	seterr(ERROR_UNIMPLEMENTED);
	return NULL;
    }
    if (!dst) {
	dst = &buf;
    }
    if (elf->e_class == ELFCLASS64) {
	*dst = *(Elf64_Phdr*)(tmp + ndx * n);
    }
    else if (elf->e_class == ELFCLASS32) {
	Elf32_Phdr *src = (Elf32_Phdr*)(tmp + ndx * n);

	check_and_copy(GElf_Word,  dst, src, p_type,   NULL);
	check_and_copy(GElf_Word,  dst, src, p_flags,  NULL);
	check_and_copy(GElf_Off,   dst, src, p_offset, NULL);
	check_and_copy(GElf_Addr,  dst, src, p_vaddr,  NULL);
	check_and_copy(GElf_Addr,  dst, src, p_paddr,  NULL);
	check_and_copy(GElf_Xword, dst, src, p_filesz, NULL);
	check_and_copy(GElf_Xword, dst, src, p_memsz,  NULL);
	check_and_copy(GElf_Xword, dst, src, p_align,  NULL);
    }
    else {
	if (valid_class(elf->e_class)) {
	    seterr(ERROR_UNIMPLEMENTED);
	}
	else {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	return NULL;
    }
    if (dst == &buf) {
	dst = (GElf_Phdr*)malloc(sizeof(GElf_Phdr));
	if (!dst) {
	    seterr(ERROR_MEM_PHDR);
	    return NULL;
	}
	*dst = buf;
    }
    return dst;
}
开发者ID:samgh1230,项目名称:experiment_data,代码行数:60,代码来源:gelfphdr.c


示例5: _elf_read

void*
_elf_read(Elf *elf, void *buffer, size_t off, size_t len) {
    void *tmp;

    elf_assert(elf);
    elf_assert(elf->e_magic == ELF_MAGIC);
    elf_assert(off >= 0 && off + len <= elf->e_size);
    if (elf->e_disabled) {
	seterr(ERROR_FDDISABLED);
    }
    else if (len) {
	off += elf->e_base;
	if (lseek(elf->e_fd, (off_t)off, SEEK_SET) != (off_t)off) {
	    seterr(ERROR_IO_SEEK);
	}
	else if (!(tmp = buffer) && !(tmp = malloc(len))) {
	    seterr(ERROR_IO_2BIG);
	}
	else if (read(elf->e_fd, tmp, len) != (int)len) {
	    seterr(ERROR_IO_READ);
	    if (tmp != buffer) {
		free(tmp);
	    }
	}
	else {
	    return tmp;
	}
    }
    return NULL;
}
开发者ID:xyuan,项目名称:Path64,代码行数:30,代码来源:input.c


示例6: elf_strptr

char*
elf_strptr(Elf *elf, size_t section, size_t offset) {
    Elf_Scn *scn;
    Elf_Data *sd;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (!(scn = elf_getscn(elf, section))) {
	return NULL;
    }
    if (scn->s_type != SHT_STRTAB) {
	seterr(ERROR_NOSTRTAB);
	return NULL;
    }
    if (offset >= 0 && offset < scn->s_size) {
	sd = NULL;
	while ((sd = elf_getdata(scn, sd))) {
	    if (sd->d_buf
	     && offset >= (size_t)sd->d_off
	     && offset < (size_t)sd->d_off + sd->d_size) {
		return (char*)sd->d_buf + (offset - sd->d_off);
	    }
	}
    }
    seterr(ERROR_BADSTROFF);
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:29,代码来源:strptr.c


示例7: elf_newdata

Elf_Data*
elf_newdata(Elf_Scn *scn) {
    Scn_Data *sd;

    if (!scn) {
	return NULL;
    }
    elf_assert(scn->s_magic == SCN_MAGIC);
    if (scn->s_index == SHN_UNDEF) {
	seterr(ERROR_NULLSCN);
    }
    else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) {
	seterr(ERROR_MEM_SCNDATA);
    }
    else {
	*sd = _elf_data_init;
	sd->sd_data_flags = ELF_F_DIRTY;
	sd->sd_freeme = 1;
	sd->sd_data.d_version = _elf_version;
	if (scn->s_data_n) {
	    scn->s_data_n->sd_link = sd;
	}
	else {
	    scn->s_data_1 = sd;
	}
	scn->s_data_n = sd;
	return &sd->sd_data;
    }
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:30,代码来源:newdata.c


示例8: gelf_msize

/*
 * Extension: report memory size
 */
size_t
gelf_msize(Elf *elf, Elf_Type type, size_t count, unsigned ver) {
    size_t n;

    if (elf) {
	if (elf->e_kind != ELF_K_ELF) {
	    seterr(ERROR_NOTELF);
	}
	else if (!valid_class(elf->e_class)) {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	else if (!valid_version(ver)) {
	    seterr(ERROR_UNKNOWN_VERSION);
	}
	else if (!valid_type(type)) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else if (!(n = _msize(elf->e_class, ver, type))) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else {
	    return count * n;
	}
    }
    return 0;
}
开发者ID:cdaffara,项目名称:symbian-oss_adapt,代码行数:29,代码来源:32.fsize.c


示例9: gelf_update_shdr

int
gelf_update_shdr(Elf_Scn *scn, GElf_Shdr *src) {
    if (!scn || !src) {
	return 0;
    }
    elf_assert(scn->s_magic == SCN_MAGIC);
    elf_assert(scn->s_elf);
    elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
    if (scn->s_elf->e_class == ELFCLASS64) {
	scn->s_shdr64 = *src;
    }
    else if (scn->s_elf->e_class == ELFCLASS32) {
	Elf32_Shdr *dst = &scn->s_shdr32;

	check_and_copy(Elf32_Word, dst, src, sh_name,      0);
	check_and_copy(Elf32_Word, dst, src, sh_type,      0);
	check_and_copy(Elf32_Word, dst, src, sh_flags,     0);
	check_and_copy(Elf32_Addr, dst, src, sh_addr,      0);
	check_and_copy(Elf32_Off,  dst, src, sh_offset,    0);
	check_and_copy(Elf32_Word, dst, src, sh_size,      0);
	check_and_copy(Elf32_Word, dst, src, sh_link,      0);
	check_and_copy(Elf32_Word, dst, src, sh_info,      0);
	check_and_copy(Elf32_Word, dst, src, sh_addralign, 0);
	check_and_copy(Elf32_Word, dst, src, sh_entsize,   0);
    }
    else if (valid_class(scn->s_elf->e_class)) {
	seterr(ERROR_UNIMPLEMENTED);
	return 0;
    }
    else {
	seterr(ERROR_UNKNOWN_CLASS);
	return 0;
    }
    return 1;
}
开发者ID:manojxantony,项目名称:compiler,代码行数:35,代码来源:gelfshdr.c


示例10: _elf_newehdr

static char*
_elf_newehdr(Elf *elf, unsigned cls) {
    size_t size;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (elf->e_readable) {
	return _elf_getehdr(elf, cls);
    }
    else if (!elf->e_ehdr) {
	size = _msize(cls, _elf_version, ELF_T_EHDR);
	elf_assert(size);
	if ((elf->e_ehdr = (char*)malloc(size))) {
	    memset(elf->e_ehdr, 0, size);
	    elf->e_free_ehdr = 1;
	    elf->e_ehdr_flags |= ELF_F_DIRTY;
	    elf->e_kind = ELF_K_ELF;
	    elf->e_class = cls;
	    return elf->e_ehdr;
	}
	seterr(ERROR_MEM_EHDR);
    }
    else if (elf->e_class != cls) {
	seterr(ERROR_CLASSMISMATCH);
    }
    else {
	elf_assert(elf->e_kind == ELF_K_ELF);
	return elf->e_ehdr;
    }
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:33,代码来源:32.newehdr.c


示例11: cgcef_nextscn

CGCEf_Scn*
cgcef_nextscn(CGCEf *cgcef, CGCEf_Scn *scn) {
    if (!cgcef) {
	return NULL;
    }
    cgcef_assert(cgcef->e_magic == CGCEF_MAGIC);
    if (scn) {
	cgcef_assert(scn->s_magic == SCN_MAGIC);
	if (scn->s_cgcef == cgcef) {
	    return scn->s_link;
	}
	seterr(ERROR_CGCEFSCNMISMATCH);
    }
    else if (cgcef->e_kind != CGCEF_K_CGCEF) {
	seterr(ERROR_NOTCGCEF);
    }
    else if (cgcef->e_ehdr || _cgcef_cook(cgcef)) {
	cgcef_assert(cgcef->e_ehdr);
	for (scn = cgcef->e_scn_1; scn; scn = scn->s_link) {
	    cgcef_assert(scn->s_magic == SCN_MAGIC);
	    cgcef_assert(scn->s_cgcef == cgcef);
	    if (scn->s_index == 1) {
		return scn;
	    }
	}
	seterr(ERROR_NOSUCHSCN);
    }
    return NULL;
}
开发者ID:BitK-,项目名称:libcgcef,代码行数:29,代码来源:nextscn.c


示例12: elf_nextscn

Elf_Scn*
elf_nextscn(Elf *elf, Elf_Scn *scn) {
    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (scn) {
	elf_assert(scn->s_magic == SCN_MAGIC);
	if (scn->s_elf == elf) {
	    return scn->s_link;
	}
	seterr(ERROR_ELFSCNMISMATCH);
    }
    else if (elf->e_kind != ELF_K_ELF) {
	seterr(ERROR_NOTELF);
    }
    else if (elf->e_ehdr || _elf_cook(elf)) {
	elf_assert(elf->e_ehdr);
	for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
	    elf_assert(scn->s_magic == SCN_MAGIC);
	    elf_assert(scn->s_elf == elf);
	    if (scn->s_index == 1) {
		return scn;
	    }
	}
	seterr(ERROR_NOSUCHSCN);
    }
    return NULL;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:29,代码来源:nextscn.c


示例13: elf_memory

Elf*
elf_memory(char *image, size_t size) {
    Elf *elf;

    elf_assert(_elf_init.e_magic == ELF_MAGIC);
    if (_elf_version == EV_NONE) {
	seterr(ERROR_VERSION_UNSET);
	return NULL;
    }
    else if (size == 0 || image == NULL) {
	/* TODO: set error code? */
	return NULL;
    }

    if (!(elf = (Elf*)malloc(sizeof(Elf)))) {
	seterr(ERROR_MEM_ELF);
	return NULL;
    }
    *elf = _elf_init;
    elf->e_size = elf->e_dsize = size;
    elf->e_data = elf->e_rawdata = image;
    elf->e_readable = 1;
    elf->e_disabled = 1;
    elf->e_memory = 1;

    _elf_check_type(elf, size);
    return elf;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:28,代码来源:begin.c


示例14: wbisect

int
wbisect(ISect *is)
{
	ZBlock *b;

	b = alloczblock(HeadSize, 1, 0);
	if(b == nil){
		/* ZZZ set error? */
		return -1;
	}

	if(packisect(is, b->data) < 0){
		seterr(ECorrupt, "can't make index section header: %r");
		freezblock(b);
		return -1;
	}
	if(writepart(is->part, PartBlank, b->data, HeadSize) < 0 || flushpart(is->part) < 0){
		seterr(EAdmin, "can't write index section header: %r");
		freezblock(b);
		return -1;
	}
	freezblock(b);

	return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:25,代码来源:index.c


示例15: initisect

ISect*
initisect(Part *part)
{
	ISect *is;
	ZBlock *b;
	int ok;

	b = alloczblock(HeadSize, 0, 0);
	if(b == nil || readpart(part, PartBlank, b->data, HeadSize) < 0){
		seterr(EAdmin, "can't read index section header: %r");
		return nil;
	}

	is = MKZ(ISect);
	if(is == nil){
		freezblock(b);
		return nil;
	}
	is->part = part;
	ok = unpackisect(is, b->data);
	freezblock(b);
	if(ok < 0){
		seterr(ECorrupt, "corrupted index section header: %r");
		freeisect(is);
		return nil;
	}

	if(is->version != ISectVersion1 && is->version != ISectVersion2){
		seterr(EAdmin, "unknown index section version %d", is->version);
		freeisect(is);
		return nil;
	}

	return initisect1(is);
}
开发者ID:99years,项目名称:plan9,代码行数:35,代码来源:index.c


示例16: elf_getshstrndx

int
elf_getshstrndx(Elf *elf, size_t *resultp) {
    size_t num = 0;
    size_t dummy;
    Elf_Scn *scn;

    if (!elf) {
	return LIBELF_FAILURE;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (resultp == NULL) {
	resultp = &dummy;	/* handle NULL pointer gracefully */
    }
    if (elf->e_kind != ELF_K_ELF) {
	seterr(ERROR_NOTELF);
	return LIBELF_FAILURE;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
	return LIBELF_FAILURE;
    }
    if (elf->e_class == ELFCLASS32) {
	num = ((Elf32_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
#if __LIBELF64
    else if (elf->e_class == ELFCLASS64) {
	num = ((Elf64_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
#endif /* __LIBELF64 */
    else {
	if (valid_class(elf->e_class)) {
	    seterr(ERROR_UNIMPLEMENTED);
	}
	else {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	return LIBELF_FAILURE;
    }
    if (num != SHN_XINDEX) {
	*resultp = num;
	return LIBELF_SUCCESS;
    }
    /*
     * look at first section header
     */
    if (!(scn = elf->e_scn_1)) {
	seterr(ERROR_NOSUCHSCN);
	return LIBELF_FAILURE;
    }
    elf_assert(scn->s_magic == SCN_MAGIC);
#if __LIBELF64
    if (elf->e_class == ELFCLASS64) {
	*resultp = scn->s_shdr64.sh_link;
	return LIBELF_SUCCESS;
    }
#endif /* __LIBELF64 */
    *resultp = scn->s_shdr32.sh_link;
    return LIBELF_SUCCESS;
}
开发者ID:samgh1230,项目名称:experiment_data,代码行数:58,代码来源:x.elfext.c


示例17: parseindex

int
parseindex(IFile *f, Index *ix)
{
	AMapN amn;
	u32int v;
	char *s;

	/*
	 * magic
	 */
	s = ifileline(f);
	if(s == nil || strcmp(s, IndexMagic) != 0){
		seterr(ECorrupt, "bad index magic for %s", f->name);
		return -1;
	}

	/*
	 * version
	 */
	if(ifileu32int(f, &v) < 0){
		seterr(ECorrupt, "syntax error: bad version number in %s", f->name);
		return -1;
	}
	ix->version = v;
	if(ix->version != IndexVersion){
		seterr(ECorrupt, "bad version number in %s", f->name);
		return -1;
	}

	/*
	 * name
	 */
	if(ifilename(f, ix->name) < 0){
		seterr(ECorrupt, "syntax error: bad index name in %s", f->name);
		return -1;
	}

	/*
	 * block size
	 */
	if(ifileu32int(f, &v) < 0){
		seterr(ECorrupt, "syntax error: bad block size number in %s", f->name);
		return -1;
	}
	ix->blocksize = v;

	if(parseamap(f, &amn) < 0)
		return -1;
	ix->nsects = amn.n;
	ix->smap = amn.map;

	if(parseamap(f, &amn) < 0)
		return -1;
	ix->narenas = amn.n;
	ix->amap = amn.map;

	return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:58,代码来源:index.c


示例18: _elf_item

static char*
_elf_item(Elf *elf, Elf_Type type, size_t n, size_t off, int *flag) {
    Elf_Data src, dst;

    *flag = 0;
    elf_assert(n);
    elf_assert(valid_type(type));
    if (off > elf->e_size) {
	seterr(ERROR_OUTSIDE);
	return NULL;
    }

    src.d_type = type;
    src.d_version = elf->e_version;
    src.d_size = n * _fsize(elf->e_class, src.d_version, type);
    elf_assert(src.d_size);
    if ((elf->e_size - off) < src.d_size) {
	seterr(truncerr(type));
	return NULL;
    }

    dst.d_version = _elf_version;
    dst.d_size = n * _msize(elf->e_class, dst.d_version, type);
    elf_assert(dst.d_size);

    elf_assert(elf->e_data);
    if (elf->e_rawdata != elf->e_data && dst.d_size <= src.d_size) {
	dst.d_buf = elf->e_data + off;
    }
    else if (!(dst.d_buf = malloc(dst.d_size))) {
	seterr(memerr(type));
	return NULL;
    }
    else {
	*flag = 1;
    }

    if (elf->e_rawdata) {
	src.d_buf = elf->e_rawdata + off;
    }
    else {
	src.d_buf = elf->e_data + off;
    }

    if (_elf_xlatetom(elf, &dst, &src)) {
	if (!*flag) {
	    elf->e_cooked = 1;
	}
	return (char*)dst.d_buf;
    }

    if (*flag) {
	free(dst.d_buf);
	*flag = 0;
    }
    return NULL;
}
开发者ID:manojxantony,项目名称:compiler,代码行数:57,代码来源:cook.c


示例19: readlump

/*
 * Some of this logic is duplicated in hdisk.c
 */
Packet*
readlump(u8int *score, int type, u32int size, int *cached)
{
	Lump *u;
	Packet *p;
	IAddr ia;
	u32int n;

	trace(TraceLump, "readlump enter");
/*
	qlock(&stats.lock);
	stats.lumpreads++;
	qunlock(&stats.lock);
*/
	if(scorecmp(score, zeroscore) == 0)
		return packetalloc();
	u = lookuplump(score, type);
	if(u->data != nil){
		trace(TraceLump, "readlump lookuplump hit");
		if(cached)
			*cached = 1;
		n = packetsize(u->data);
		if(n > size){
			seterr(EOk, "read too small: asked for %d need at least %d", size, n);
			putlump(u);

			return nil;
		}
		p = packetdup(u->data, 0, n);
		putlump(u);
		return p;
	}

	if(cached)
		*cached = 0;

	if(lookupscore(score, type, &ia) < 0){
		/* ZZZ place to check for someone trying to guess scores */
		seterr(EOk, "no block with score %V/%d exists", score, type);

		putlump(u);
		return nil;
	}
	if(ia.size > size){
		seterr(EOk, "read too small 1: asked for %d need at least %d", size, ia.size);

		putlump(u);
		return nil;
	}

	trace(TraceLump, "readlump readilump");
	p = readilump(u, &ia, score);
	putlump(u);

	trace(TraceLump, "readlump exit");
	return p;
}
开发者ID:00001,项目名称:plan9port,代码行数:60,代码来源:lump.c


示例20: _elf_newphdr

static char*
_elf_newphdr(Elf *elf, size_t count, unsigned cls) {
    char *phdr = NULL;
    size_t size;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (!elf->e_ehdr && !elf->e_readable) {
	seterr(ERROR_NOEHDR);
    }
    else if (elf->e_kind != ELF_K_ELF) {
	seterr(ERROR_NOTELF);
    }
    else if (elf->e_class != cls) {
	seterr(ERROR_CLASSMISMATCH);
    }
    else if (elf->e_ehdr || _elf_cook(elf)) {
	size = _msize(cls, _elf_version, ELF_T_PHDR);
	elf_assert(size);
	if (count) {
	    if (!(phdr = (char*)malloc(count * size))) {
		seterr(ERROR_MEM_PHDR);
		return NULL;
	    }
	    memset(phdr, 0, count * size);
	}
	elf_assert(elf->e_ehdr);
	if (cls == ELFCLASS32) {
	    ((Elf32_Ehdr*)elf->e_ehdr)->e_phnum = elf->e_phnum = count;
	}
#if __LIBELF64
	else if (cls == ELFCLASS64) {
	    ((Elf64_Ehdr*)elf->e_ehdr)->e_phnum = elf->e_phnum = count;
	}
#endif /* __LIBELF64 */
	else {
	    seterr(ERROR_UNIMPLEMENTED);
	    if (phdr) {
		free(phdr);
	    }
	    return NULL;
	}
	if (elf->e_free_phdr) {
	    elf_assert(elf->e_phdr);
	    free(elf->e_phdr);
	}
	elf->e_phdr = phdr;
	elf->e_free_phdr = phdr ? 1 : 0;
	elf->e_phdr_flags |= ELF_F_DIRTY;
	elf->e_ehdr_flags |= ELF_F_DIRTY;
	return phdr;
    }
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:56,代码来源:32.newphdr.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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