本文整理汇总了C++中de_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ de_malloc函数的具体用法?C++ de_malloc怎么用?C++ de_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了de_malloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}