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

C++ de_malloc函数代码示例

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

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



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

示例1: de_malloc

static struct de_linereader *de_linereader_create(deark *c, dbuf *f)
{
	struct de_linereader *lr;
	lr = de_malloc(c, sizeof(struct de_linereader));
	lr->f = f;
	return lr;
}
开发者ID:jsummers,项目名称:deark,代码行数:7,代码来源:unifont.c


示例2: de_malloc

struct de_bitmap_font *de_create_bitmap_font(deark *c)
{
	struct de_bitmap_font *font;
	font = de_malloc(c, sizeof(struct de_bitmap_font));
	font->index_of_replacement_char = -1;
	return font;
}
开发者ID:jsummers,项目名称:deark,代码行数:7,代码来源:deark-font.c


示例3: de_run_wri

static void de_run_wri(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;

	d = de_malloc(c, sizeof(lctx));

	if(c->input_encoding==DE_ENCODING_UNKNOWN)
		d->input_encoding = DE_ENCODING_WINDOWS1252;
	else
		d->input_encoding = c->input_encoding;

	d->extract_text = de_get_ext_option_bool(c, "wri:extracttext", 1);
	d->extract_ole = de_get_ext_option_bool(c, "wri:extractole",
		(c->extract_level>=2)?1:0);

	pos = 0;
	if(!do_header(c, d, pos)) goto done;
	if(d->extract_text) {
		do_html_begin(c, d);
	}

	do_para_info(c, d);

done:
	do_html_end(c, d);
	de_free(c, d);
}
开发者ID:jsummers,项目名称:deark,代码行数:28,代码来源:wri.c


示例4: newScoredMafLine

scoredMafLine_t* newScoredMafLine(void) {
    scoredMafLine_t *m = (scoredMafLine_t *) de_malloc(sizeof(*m));
    m->mafLine = NULL;
    m->next = NULL;
    m->score = 0.0;
    return m;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:7,代码来源:mafStrander.c


示例5: de_run_gzip

static void de_run_gzip(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	i64 member_size;

	d = de_malloc(c, sizeof(lctx));
	d->crco = de_crcobj_create(c, DE_CRCOBJ_CRC32_IEEE);

	pos = 0;
	while(1) {
		if(pos >= c->infile->len) break;
		if(!do_gzip_read_member(c, d, pos, &member_size)) {
			break;
		}
		if(member_size<=0) break;

		pos += member_size;
	}
	dbuf_close(d->output_file);

	if(d) {
		de_crcobj_destroy(d->crco);
		de_free(c, d);
	}
}
开发者ID:jsummers,项目名称:deark,代码行数:26,代码来源:gzip.c


示例6: findBestDupes

void findBestDupes(duplicate_t *head, char *consensus) {
    // For each duplicate list, go through its mafline list and find the best line and move it
    // to the head of the list.
    duplicate_t *d = head;
    scoredMafLine_t *sml = NULL;
    while (d != NULL) {
        if (d->numSequences < 2) {
            // if there's only one sequence, who cares
            d = d->next;
            continue;
        }
        // score all the maf lines
        sml = d->headScoredMaf;
        while (sml != NULL) {
            sml->score = scoreSequence(consensus, maf_mafLine_getSequence(sml->mafLine));
            sml = sml->next;
        }
        // sort on scores
        scoredMafLine_t **mafLineArray = (scoredMafLine_t**) de_malloc(sizeof(*mafLineArray) * d->numSequences);
        populateMafLineArray(d->headScoredMaf, mafLineArray);
        qsort(mafLineArray, d->numSequences, sizeof(scoredMafLine_t *), cmp_by_score);
        // move the top score to the head of the list
        d->headScoredMaf = mafLineArray[0];
        sml = d->headScoredMaf;
        for (unsigned i = 1; i < d->numSequences; ++i) {
            // rebuild the linked list
            sml->next = mafLineArray[i];
            sml = sml->next;
        }
        sml->next = NULL;
        d = d->next;
        free(mafLineArray);
    }
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:34,代码来源:mafDuplicateFilter.c


示例7: parseOptions

void parseOptions(int argc, char **argv, char *filename) {
    int c;
    int setMName = 0;
    while (1) {
        static struct option longOptions[] = {
            {"debug", no_argument, 0, 'd'},
            {"verbose", no_argument, 0, 'v'},
            {"help", no_argument, 0, 'h'},
            {"version", no_argument, 0, 0},
            {"maf",  required_argument, 0, 'm'},
            {0, 0, 0, 0}
        };
        int longIndex = 0;
        c = getopt_long(argc, argv, "d:m:h:v",
                        longOptions, &longIndex);
        if (c == -1)
            break;
        switch (c) {
        case 0:
            if (strcmp("version", longOptions[longIndex].name) == 0) {
                version();
                exit(EXIT_SUCCESS);
            }
            break;
        case 'm':
            setMName = 1;
            sscanf(optarg, "%s", filename);
            break;
        case 'v':
            g_verbose_flag++;
            break;
        case 'd':
            g_debug_flag = 1;
            break;
        case 'h':
        case '?':
            usage();
            break;
        default:
            abort();
        }
    }
    if (!setMName) {
        fprintf(stderr, "specify --maf\n");
        usage();
    }
    // Check there's nothing left over on the command line
    if (optind < argc) {
        char *errorString = de_malloc(kMaxStringLength);
        strcpy(errorString, "Unexpected arguments:");
        while (optind < argc) {
            strcat(errorString, " ");
            strcat(errorString, argv[optind++]);
        }
        fprintf(stderr, "%s\n", errorString);
        free(errorString);
        usage();
    }
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:59,代码来源:mafDuplicateFilter.c


示例8: maf_newMfa

mafFileApi_t* maf_newMfa(const char *filename, char const *mode) {
  mafFileApi_t *mfa = (mafFileApi_t *) de_malloc(sizeof(*mfa));
  mfa->lineNumber = 0;
  mfa->lastLine = NULL;
  mfa->mfp = de_fopen(filename, mode);
  mfa->filename = de_strdup(filename);
  return mfa;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:8,代码来源:sharedMaf.c


示例9: newDuplicate

duplicate_t* newDuplicate(void) {
    duplicate_t *d = (duplicate_t *) de_malloc(sizeof(*d));
    d->species = NULL;
    d->headScoredMaf = NULL;
    d->reported = false;
    d->next = NULL;
    return d;
}
开发者ID:sorrywm,项目名称:mafTools,代码行数:8,代码来源:mafBlockDuplicateFilter.c


示例10: handler_attachedfile_start

static void handler_attachedfile_start(deark *c, lctx *d, struct handler_params *hp)
{
	if(d->attachmentctx) {
		destroy_attachment_data(c, d);
	}

	d->attachmentctx = de_malloc(c, sizeof(struct attachmentctx_struct));
}
开发者ID:jsummers,项目名称:deark,代码行数:8,代码来源:ebml.c


示例11: maf_newMafBlockFromString

mafBlock_t* maf_newMafBlockFromString(const char *s, uint64_t lineNumber) {
  if (s[0] != 'a') {
    char *error = de_malloc(kMaxStringLength);
    sprintf(error,
            "Unable to create maf block from input, "
            "first line does not start with 'a': %s", s);
    maf_failBadFormat(lineNumber, error);
  }
  mafBlock_t* mb = maf_newMafBlock();
  mafLine_t* ml = NULL;
  maf_mafBlock_setLineNumber(mb, lineNumber);
  char *cline = (char *) de_malloc(strlen(s) + 1);
  strcpy(cline, s);
  char *cline_orig = cline;
  char **ptr = &cline;
  char *tkn = NULL;
  tkn = de_strtok(ptr, '\n');
  maf_mafBlock_incrementLineNumber(mb);
  maf_mafBlock_incrementNumberOfLines(mb);
  ml = maf_newMafLineFromString(tkn, lineNumber++);
  maf_mafBlock_setHeadLine(mb, ml);
  free(tkn);
  tkn = NULL;
  tkn = de_strtok(ptr, '\n');
  while (tkn != NULL) {
    maf_mafBlock_incrementLineNumber(mb);
    maf_mafBlock_incrementNumberOfLines(mb);
    maf_mafLine_setNext(ml, maf_newMafLineFromString(tkn, lineNumber++));
    ml = maf_mafLine_getNext(ml);
    if (maf_mafLine_getType(ml) == 's') {
      maf_mafBlock_incrementNumberOfSequences(mb);
      mb->sequenceFieldLength = maf_mafLine_getSequenceFieldLength(ml);
    }
    maf_mafBlock_setTailLine(mb, ml);
    free(tkn);
    tkn = NULL;
    tkn = de_strtok(ptr, '\n');
  }
  free(cline_orig);
  cline_orig = NULL;
  return mb;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:42,代码来源:sharedMaf.c


示例12: maf_mafBlock_appendToAlignmentBlock

void maf_mafBlock_appendToAlignmentBlock(mafBlock_t *m, char *s) {
  mafLine_t *ml = maf_mafBlock_getHeadLine(m);
  char *line = maf_mafLine_getLine(ml);
  assert(line[0] == 'a');
  char *newline = (char*) de_malloc(strlen(line) + strlen(s) + 1);
  newline[0] = '\0';
  strcat(newline, line);
  strcat(newline, s);
  free(ml->line);
  ml->line = newline;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:11,代码来源:sharedMaf.c


示例13: maf_newMafBlock

mafBlock_t* maf_newMafBlock(void) {
  mafBlock_t *mb = (mafBlock_t *) de_malloc(sizeof(*mb));
  mb->next = NULL;
  mb->headLine = NULL;
  mb->tailLine = NULL;
  mb->lineNumber = 0;
  mb->numberOfSequences = 0;
  mb->numberOfLines = 0;
  mb->sequenceFieldLength = 0;
  return mb;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:11,代码来源:sharedMaf.c


示例14: fixup_codepoints

// Put the actual codepont to use in the font->char_array[].codepoint_tmp field.
static void fixup_codepoints(deark *c, struct font_render_ctx *fctx)
{
	i64 i;
	i32 c1;
	i64 num_uncoded_chars = 0;
	u8 *used_codepoint_map = NULL;
	u8 codepoint_already_used;

	if(!fctx->render_as_unicode) {
		for(i=0; i<fctx->font->num_chars; i++) {
			fctx->codepoint_tmp[i] = fctx->font->char_array[i].codepoint_nonunicode;
		}
		goto done;
	}

	// An array of bits to remember if we've seen a codepoint before (BMP only).
	// A character with a duplicate codepoint will be moved to another
	// location, so that it doesn't get painted over the previous one.
	used_codepoint_map = de_malloc(c, 65536/8);

	for(i=0; i<fctx->font->num_chars; i++) {
		if(!is_valid_char(&fctx->font->char_array[i])) continue;
		c1 = fctx->font->char_array[i].codepoint_unicode;

		codepoint_already_used = 0;
		if(c1>=0 && c1<65536) {
			// Check if we've seen this codepoint before.
			codepoint_already_used = used_codepoint_map[c1/8] & (1<<(c1%8));

			// Remember that we've seen this codepoint.
			used_codepoint_map[c1/8] |= 1<<(c1%8);
		}

		if(codepoint_already_used || c1==DE_CODEPOINT_INVALID) {
			if(codepoint_already_used) {
				de_dbg2(c, "moving duplicate codepoint U+%04x at index %d to private use area",
					(unsigned int)c1, (int)i);
			}
			// Move uncoded characters to a Private Use area.
			// (Supplementary Private Use Area-A = U+F0000 - U+FFFFD)
			if(DE_CODEPOINT_MOVED + num_uncoded_chars <= DE_CODEPOINT_MOVED_MAX) {
				fctx->codepoint_tmp[i] = (i32)(DE_CODEPOINT_MOVED + num_uncoded_chars);
				num_uncoded_chars++;
			}
		}
		else {
			fctx->codepoint_tmp[i] = c1;
		}
	}

done:
	de_free(c, used_codepoint_map);
}
开发者ID:jsummers,项目名称:deark,代码行数:54,代码来源:deark-font.c


示例15: de_run_woz

static void de_run_woz(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	struct de_iffctx *ictx = NULL;
	u32 crc;
	i64 pos = 0;

	// WOZ has a 12-byte header, then sequence of chunks that are basically the
	// same format as RIFF.
	d = de_malloc(c, sizeof(lctx));
	ictx = de_malloc(c, sizeof(struct de_iffctx));

	ictx->userdata = (void*)d;
	ictx->preprocess_chunk_fn = my_preprocess_woz_chunk_fn;
	ictx->handle_chunk_fn = my_woz_chunk_handler;
	ictx->f = c->infile;
	ictx->is_le = 1;
	ictx->reversed_4cc = 0;

	if(ictx->f->len<12) goto done;
	de_dbg(c, "header at %d", (int)pos);
	de_dbg_indent(c, 1);
	pos += 3; // "WOZ" part of signature
	d->wozver = dbuf_getbyte_p(ictx->f, &pos);
	de_dbg(c, "format version: '%c'", de_byte_to_printable_char(d->wozver));
	if(d->wozver<'1' || d->wozver>'2') {
		de_err(c, "Unsupported WOZ format version");
		goto done;
	}
	pos += 4; // rest of signature
	crc = (u32)dbuf_getu32le_p(ictx->f, &pos);
	de_dbg(c, "crc: 0x%08x", (unsigned int)crc);
	de_dbg_indent(c, -1);

	de_fmtutil_read_iff_format(c, ictx, pos, ictx->f->len-pos);

done:
	de_free(c, ictx);
	de_free(c, d);
}
开发者ID:jsummers,项目名称:deark,代码行数:40,代码来源:apple2-dsk.c


示例16: maf_newMafBlockListFromString

mafBlock_t* maf_newMafBlockListFromString(const char *s, uint64_t lineNumber) {
  // given a string, walk through and create a mafBlock_t linked list
  // for all maf blocks in the string
  mafBlock_t *head = NULL, *mb = NULL, *tmp = NULL;
  char *block_s = NULL;
  size_t len, start = 0, stop;
  len = strlen(s);
  for (stop = start + 1; stop < len; ++stop) {
    if (s[stop] == 'a' && s[stop - 1] == '\n') {
      block_s = (char *) de_malloc(stop - start + 2);
      strncpy(block_s, s + start, stop - start + 1);
      block_s[stop - start + 1] = '\0';
      tmp = maf_newMafBlockFromString(block_s, lineNumber);
      if (head == NULL) {
        mb = tmp;
        head = mb;
      } else {
        maf_mafBlock_setNext(mb, tmp);
        mb = maf_mafBlock_getNext(mb);
      }
      free(block_s);
      block_s = NULL;
      start = stop;
    }
  }
  block_s = (char *) de_malloc(stop - start + 2);
  strncpy(block_s, s + start, stop - start + 1);
  block_s[stop - start + 1] = '\0';
  tmp = maf_newMafBlockFromString(block_s, lineNumber);
  if (head == NULL) {
    mb = tmp;
    head = mb;
  } else {
    maf_mafBlock_setNext(mb, tmp);
    mb = maf_mafBlock_getNext(mb);
  }
  free(block_s);
  block_s = NULL;
  return head;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:40,代码来源:sharedMaf.c


示例17: de_malloc

dbuf *dbuf_create_membuf(deark *c, i64 initialsize, unsigned int flags)
{
	dbuf *f;
	f = de_malloc(c, sizeof(dbuf));
	f->c = c;
	f->btype = DBUF_TYPE_MEMBUF;
	f->max_len_hard = DE_MAX_MEMBUF_SIZE;

	if(initialsize>0) {
		if(initialsize > f->max_len_hard) {
			do_on_dbuf_size_exceeded(f);
		}
		f->membuf_buf = de_malloc(c, initialsize);
		f->membuf_alloc = initialsize;
	}

	if(flags&0x01) {
		dbuf_set_length_limit(f, initialsize);
	}

	return f;
}
开发者ID:jsummers,项目名称:deark,代码行数:22,代码来源:deark-dbuf.c


示例18: maf_readBlockBody

mafBlock_t* maf_readBlockBody(mafFileApi_t *mfa) {
  extern const int kMaxStringLength;
  mafBlock_t *thisBlock = maf_newMafBlock();
  if (mfa->lastLine != NULL) {
    // this is only invoked when the header is not followed by a blank line
    mafLine_t *ml = maf_newMafLineFromString(mfa->lastLine, mfa->lineNumber);
    if (ml->type == 's') {
      ++(thisBlock->numberOfSequences);
      if (thisBlock->sequenceFieldLength == 0) {
        thisBlock->sequenceFieldLength = maf_mafLine_getSequenceFieldLength(ml);
      }
    }
    ++(thisBlock->numberOfLines);
    thisBlock->headLine = ml;
    thisBlock->tailLine = ml;
    free(mfa->lastLine);
    mfa->lastLine = NULL;
  }
  int64_t n = kMaxStringLength;
  char *line = (char*) de_malloc(n);
  thisBlock->lineNumber = mfa->lineNumber;
  while(de_getline(&line, &n, mfa->mfp) != -1) {
    ++(mfa->lineNumber);
    if (maf_isBlankLine(line)) {
      if (thisBlock->headLine == NULL) {
        // this handles multiple blank lines in a row
        continue;
      } else {
        break;
      }
    }
    mafLine_t *ml = maf_newMafLineFromString(line, mfa->lineNumber);
    if (thisBlock->headLine == NULL) {
      thisBlock->headLine = ml;
      thisBlock->tailLine = ml;
    } else {
      thisBlock->tailLine->next = ml;
      thisBlock->tailLine = ml;
    }
    if (ml->type == 's') {
      ++(thisBlock->numberOfSequences);
      if (thisBlock->sequenceFieldLength == 0) {
        thisBlock->sequenceFieldLength = maf_mafLine_getSequenceFieldLength(ml);
      }
    }
    ++(thisBlock->numberOfLines);
  }
  free(line);
  line = NULL;
  return thisBlock;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:51,代码来源:sharedMaf.c


示例19: strlen

char *copyChromosomeName(const char *s) {
  // return a copy of the string, minus species information
  // hg18.chr1 -> chr1
  unsigned n, l = 0;
  n = strlen(s);
  for (l = 0; l < n; ++l) {
    // find the first instance of a `.' character
    if (s[l] == '.') {
      l += 1;
      break;
    }
  }
  if (l < n) {
    char *copy = (char *) de_malloc(n - l + 1);
    strncpy(copy, s + l, n - l);
    copy[n - l] = '\0';
    return copy;
  } else {
    char *copy = (char *) de_malloc(1);
    copy[0] = '\0';
    return copy;
  }
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:23,代码来源:sharedMaf.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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