本文整理汇总了C++中copy_struct函数的典型用法代码示例。如果您正苦于以下问题:C++ copy_struct函数的具体用法?C++ copy_struct怎么用?C++ copy_struct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy_struct函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: erts_deliver_exit_message
void
erts_deliver_exit_message(Eterm from, Process *to, ErtsProcLocks *to_locksp,
Eterm reason, Eterm token)
{
Eterm mess;
Eterm save;
Eterm from_copy;
Uint sz_reason;
Uint sz_token;
Uint sz_from;
Eterm* hp;
Eterm temptoken;
ErlHeapFragment* bp = NULL;
if (token != NIL
#ifdef USE_VM_PROBES
&& token != am_have_dt_utag
#endif
) {
ASSERT(is_tuple(token));
sz_reason = size_object(reason);
sz_token = size_object(token);
sz_from = size_object(from);
bp = new_message_buffer(sz_reason + sz_from + sz_token + 4);
hp = bp->mem;
mess = copy_struct(reason, sz_reason, &hp, &bp->off_heap);
from_copy = copy_struct(from, sz_from, &hp, &bp->off_heap);
save = TUPLE3(hp, am_EXIT, from_copy, mess);
hp += 4;
/* the trace token must in this case be updated by the caller */
seq_trace_output(token, save, SEQ_TRACE_SEND, to->common.id, NULL);
temptoken = copy_struct(token, sz_token, &hp, &bp->off_heap);
erts_queue_message(to, to_locksp, bp, save, temptoken);
} else {
ErlOffHeap *ohp;
sz_reason = size_object(reason);
sz_from = IS_CONST(from) ? 0 : size_object(from);
hp = erts_alloc_message_heap(sz_reason+sz_from+4,
&bp,
&ohp,
to,
to_locksp);
mess = copy_struct(reason, sz_reason, &hp, ohp);
from_copy = (IS_CONST(from)
? from
: copy_struct(from, sz_from, &hp, ohp));
save = TUPLE3(hp, am_EXIT, from_copy, mess);
erts_queue_message(to, to_locksp, bp, save, NIL);
}
}
开发者ID:users-tree,项目名称:alex,代码行数:53,代码来源:erl_message.c
示例2: init_listbox
static widget_handler_status_T
init_listbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
{
struct hierbox_browser *browser = (struct hierbox_browser *)dlg_data->dlg->udata2;
struct listbox_data *box = get_listbox_widget_data(widget_data);
/* Try to restore the position from last time */
if (!list_empty(browser->root.child) && browser->box_data.items) {
copy_struct(box, &browser->box_data);
traverse_listbox_items_list((struct listbox_item *)browser->root.child.next, box, 0, 0,
check_old_state, box);
box->sel = (!box->sel) ? browser->box_data.sel : NULL;
box->top = (!box->top) ? browser->box_data.top : NULL;
if (!box->sel) box->sel = box->top;
if (!box->top) box->top = box->sel;
}
box->ops = browser->ops;
box->items = &browser->root.child;
add_to_list(browser->boxes, box);
return EVENT_PROCESSED;
}
开发者ID:rkd77,项目名称:elinks-tv,代码行数:25,代码来源:listbox.c
示例3: port_set_data_2
BIF_RETTYPE port_set_data_2(BIF_ALIST_2)
{
Port* prt;
Eterm portid = BIF_ARG_1;
Eterm data = BIF_ARG_2;
prt = id_or_name2port(BIF_P, portid);
if (!prt) {
BIF_ERROR(BIF_P, BADARG);
}
if (prt->bp != NULL) {
free_message_buffer(prt->bp);
prt->bp = NULL;
}
if (IS_CONST(data)) {
prt->data = data;
} else {
Uint size;
ErlHeapFragment* bp;
Eterm* hp;
size = size_object(data);
prt->bp = bp = new_message_buffer(size);
hp = bp->mem;
prt->data = copy_struct(data, size, &hp, &bp->off_heap);
}
erts_smp_port_unlock(prt);
BIF_RET(am_true);
}
开发者ID:Korn1699,项目名称:otp,代码行数:29,代码来源:erl_bif_port.c
示例4: port_get_data_1
BIF_RETTYPE port_get_data_1(BIF_ALIST_1)
{
/*
* This is not a signal. See comment above.
*/
Eterm res;
erts_aint_t data;
Port* prt;
prt = data_lookup_port(BIF_P, BIF_ARG_1);
if (!prt)
BIF_ERROR(BIF_P, BADARG);
data = erts_smp_atomic_read_ddrb(&prt->data);
if (data == (erts_aint_t)NULL)
BIF_ERROR(BIF_P, BADARG); /* Port terminated by racing thread */
if ((data & 0x3) != 0) {
res = (Eterm) (UWord) data;
ASSERT(is_immed(res));
}
else {
ErtsPortDataHeap *pdhp = (ErtsPortDataHeap *) data;
Eterm *hp = HAlloc(BIF_P, pdhp->hsize);
res = copy_struct(pdhp->data, pdhp->hsize, &hp, &MSO(BIF_P));
}
BIF_RET(res);
}
开发者ID:crownedgrouse,项目名称:otp,代码行数:29,代码来源:erl_bif_port.c
示例5: deflate_open
static int
deflate_open(int window_size, struct stream_encoded *stream, int fd)
{
/* A zero-initialized z_stream. The compiler ensures that all
* pointer members in it are null. (Can't do this with memset
* because C99 does not require all-bits-zero to be a null
* pointer.) */
static const z_stream null_z_stream = {0};
int err;
struct deflate_enc_data *data = mem_alloc(sizeof(*data));
stream->data = NULL;
if (!data) {
return -1;
}
/* Initialize all members of *data, except data->buf[], which
* will be initialized on demand by deflate_read. */
copy_struct(&data->deflate_stream, &null_z_stream);
data->fdread = fd;
data->last_read = 0;
data->after_first_read = 0;
data->after_end = 0;
err = inflateInit2(&data->deflate_stream, window_size);
if (err != Z_OK) {
mem_free(data);
return -1;
}
stream->data = data;
return 0;
}
开发者ID:methril,项目名称:elinks,代码行数:34,代码来源:deflate.c
示例6: ses_forward
/** If @a loaded_in_frame is set, this was called just to indicate a move inside
* a frameset, and we basically just reset the appropriate frame's view_state in
* that case. When clicking on a link inside a frame, the frame URI is somehow
* updated and added to the files-to-load queue, then ses_forward() is called
* with @a loaded_in_frame unset, duplicating the whole frameset's location,
* then later the file-to-load callback calls it for the particular frame with
* @a loaded_in_frame set. */
struct view_state *
ses_forward(struct session *ses, int loaded_in_frame)
{
struct location *loc = NULL;
struct view_state *vs;
if (!loaded_in_frame) {
free_files(ses);
mem_free_set(&ses->search_word, NULL);
}
x:
if (!loaded_in_frame) {
loc = mem_calloc(1, sizeof(*loc));
if (!loc) return NULL;
copy_struct(&loc->download, &ses->loading);
}
if (ses->task.target.frame && *ses->task.target.frame) {
struct frame *frame;
assertm(have_location(ses), "no location yet");
if_assert_failed return NULL;
if (!loaded_in_frame) {
copy_location(loc, cur_loc(ses));
add_to_history(&ses->history, loc);
}
frame = ses_find_frame(ses, ses->task.target.frame);
if (!frame) {
if (!loaded_in_frame) {
del_from_history(&ses->history, loc);
destroy_location(loc);
}
mem_free_set(&ses->task.target.frame, NULL);
goto x;
}
vs = &frame->vs;
if (!loaded_in_frame) {
destroy_vs(vs, 1);
init_vs(vs, ses->loading_uri, vs->plain);
} else {
done_uri(vs->uri);
vs->uri = get_uri_reference(ses->loading_uri);
if (vs->doc_view) {
/* vs->doc_view itself will get detached in
* render_document_frames(), but that's too
* late for us. */
vs->doc_view->vs = NULL;
vs->doc_view = NULL;
}
#ifdef CONFIG_ECMASCRIPT
vs->ecmascript_fragile = 1;
#endif
}
} else {
开发者ID:ezc,项目名称:elinks,代码行数:66,代码来源:task.c
示例7: copy_opt
NONSTATIC_INLINE void
copy_opt(struct document_options *o1, struct document_options *o2)
{
copy_struct(o1, o2);
o1->framename = stracpy(o2->framename);
o1->image_link.prefix = stracpy(get_opt_str("document.browse.images.image_link_prefix", NULL));
o1->image_link.suffix = stracpy(get_opt_str("document.browse.images.image_link_suffix", NULL));
}
开发者ID:Efreak,项目名称:elinks,代码行数:8,代码来源:options.c
示例8: enif_make_copy
ERL_NIF_TERM enif_make_copy(ErlNifEnv* dst_env, ERL_NIF_TERM src_term)
{
Uint sz;
Eterm* hp;
sz = size_object(src_term);
hp = alloc_heap(dst_env, sz);
return copy_struct(src_term, sz, &hp, &MSO(dst_env->proc));
}
开发者ID:a5an0,项目名称:otp,代码行数:8,代码来源:erl_nif.c
示例9: parse_sgml_attributes
static inline void
parse_sgml_attributes(struct dom_stack *stack, struct dom_scanner *scanner)
{
struct dom_scanner_token name;
assert(dom_scanner_has_tokens(scanner)
&& (get_dom_scanner_token(scanner)->type == SGML_TOKEN_ELEMENT_BEGIN
|| (get_dom_stack_top(stack)->node->type == DOM_NODE_PROCESSING_INSTRUCTION)));
if (get_dom_scanner_token(scanner)->type == SGML_TOKEN_ELEMENT_BEGIN)
skip_dom_scanner_token(scanner);
while (dom_scanner_has_tokens(scanner)) {
struct dom_scanner_token *token = get_dom_scanner_token(scanner);
assert(token);
switch (token->type) {
case SGML_TOKEN_TAG_END:
skip_dom_scanner_token(scanner);
/* and return */
case SGML_TOKEN_ELEMENT:
case SGML_TOKEN_ELEMENT_BEGIN:
case SGML_TOKEN_ELEMENT_END:
case SGML_TOKEN_ELEMENT_EMPTY_END:
return;
case SGML_TOKEN_IDENT:
copy_struct(&name, token);
/* Skip the attribute name token */
token = get_next_dom_scanner_token(scanner);
if (token && token->type == '=') {
/* If the token is not a valid value token
* ignore it. */
token = get_next_dom_scanner_token(scanner);
if (token
&& token->type != SGML_TOKEN_IDENT
&& token->type != SGML_TOKEN_ATTRIBUTE
&& token->type != SGML_TOKEN_STRING)
token = NULL;
} else {
token = NULL;
}
add_sgml_attribute(stack, &name, token);
/* Skip the value token */
if (token)
skip_dom_scanner_token(scanner);
break;
default:
skip_dom_scanner_token(scanner);
}
}
}
开发者ID:ohmori7,项目名称:kcn-tools,代码行数:58,代码来源:parser.c
示例10: erts_msg_distext2heap
Eterm
erts_msg_distext2heap(Process *pp,
ErtsProcLocks *plcksp,
ErlHeapFragment **bpp,
Eterm *tokenp,
ErtsDistExternal *dist_extp)
{
Eterm msg;
Uint tok_sz = 0;
Eterm *hp = NULL;
ErtsHeapFactory factory;
Sint sz;
*bpp = NULL;
sz = erts_decode_dist_ext_size(dist_extp);
if (sz < 0)
goto decode_error;
if (is_not_nil(*tokenp)) {
ErlHeapFragment *heap_frag = erts_dist_ext_trailer(dist_extp);
tok_sz = heap_frag->used_size;
sz += tok_sz;
}
if (pp) {
ErlOffHeap *ohp;
hp = erts_alloc_message_heap(sz, bpp, &ohp, pp, plcksp);
}
else {
*bpp = new_message_buffer(sz);
hp = (*bpp)->mem;
}
erts_factory_message_init(&factory, pp, hp, *bpp);
msg = erts_decode_dist_ext(&factory, dist_extp);
if (is_non_value(msg))
goto decode_error;
if (is_not_nil(*tokenp)) {
ErlHeapFragment *heap_frag = erts_dist_ext_trailer(dist_extp);
hp = erts_produce_heap(&factory, tok_sz, 0);
*tokenp = copy_struct(*tokenp, tok_sz, &hp, factory.off_heap);
erts_cleanup_offheap(&heap_frag->off_heap);
}
erts_free_dist_ext_copy(dist_extp);
erts_factory_close(&factory);
return msg;
decode_error:
if (is_not_nil(*tokenp)) {
ErlHeapFragment *heap_frag = erts_dist_ext_trailer(dist_extp);
erts_cleanup_offheap(&heap_frag->off_heap);
}
erts_free_dist_ext_copy(dist_extp);
*bpp = NULL;
return THE_NON_VALUE;
}
开发者ID:users-tree,项目名称:alex,代码行数:53,代码来源:erl_message.c
示例11: copy_object
/*
* Copy object "obj" to process p.
*/
Eterm
copy_object(Eterm obj, Process* to)
{
Uint size = size_object(obj);
Eterm* hp = HAlloc(to, size);
Eterm res;
res = copy_struct(obj, size, &hp, &to->off_heap);
#ifdef DEBUG
if (eq(obj, res) == 0) {
erl_exit(ERTS_ABORT_EXIT, "copy not equal to source\n");
}
#endif
return res;
}
开发者ID:Enouk,项目名称:iErl14,代码行数:18,代码来源:copy.c
示例12: InitBuffers
/*
* InitBuffers()
*
* This function initializes the message buffers.
*/
void InitBuffers()
{
static SListBase MsgBase = { NULL, ChkCC, NULL, free, strdup };
copy_struct(MsgBase, msgBuf.mbCC);
copy_struct(MsgBase, msgBuf.mbOverride);
copy_struct(MsgBase, msgBuf.mbInternal);
copy_struct(MsgBase, msgBuf.mbForeign);
copy_struct(MsgBase, tempMess.mbOverride);
copy_struct(MsgBase, tempMess.mbCC);
copy_struct(MsgBase, tempMess.mbInternal);
copy_struct(MsgBase, tempMess.mbForeign);
msgBuf.mbtext = GetDynamic(MAXTEXT);
tempMess.mbtext = GetDynamic(MAXTEXT);
}
开发者ID:dylancarlson,项目名称:citadel-86,代码行数:22,代码来源:LIBMSG.C
示例13: main
/**
* Print out Sesame Street letters and numbers of the day, making
* sure to delete your memory when you're done with it.
*
* This code asks for a day, letter, and number, and then prints
* them out as "<day> is sponsored by the letter <letter> and the number <number>"
*
* this code should work, but doesn't because some of the helper
* functions are broken.
*/
int main() {
sponsorships *temp_day, *today;
temp_day = init_day();
today = init_day();
printf("day letter number: ");
scanf("%s %c %d", temp_day->day, &(temp_day->letter), &(temp_day->number));
copy_struct(today, temp_day);
destroy(temp_day);
print_struct(today);
destroy(today);
return 0;
}
开发者ID:HKNTutorials,项目名称:memory-intro,代码行数:26,代码来源:copy.c
示例14: decode_terminal_application_key
/** Decode an escape sequence that begins with SS3 (SINGLE SHIFT 3).
* These are used for application cursor keys and the application keypad.
* @returns one of:
* - -1 if the escape sequence is not yet complete; the caller sets a timer.
* - 0 if the escape sequence should be parsed by some other function.
* - The length of the escape sequence otherwise.
* Returning >0 does not imply this function has altered @a *ev. */
static int
decode_terminal_application_key(struct itrm *itrm, struct interlink_event *ev)
{
unsigned char c;
struct interlink_event_keyboard kbd = { KBD_UNDEF, KBD_MOD_NONE };
assert(itrm->in.queue.len >= 2);
assert(itrm->in.queue.data[0] == ASCII_ESC);
assert(itrm->in.queue.data[1] == 0x4F); /* == 'O', incidentally */
if_assert_failed return 0;
if (itrm->in.queue.len < 3) return -1;
/* According to ECMA-35 section 8.4, a single (possibly multibyte)
* character follows the SS3. We now assume the code identifies
* GL as the single-shift area and the designated set has 94
* characters. */
c = itrm->in.queue.data[2];
if (c < 0x21 || c > 0x7E) return 0;
switch (c) { /* Terminfo $TERM */
case ' ': kbd.key = ' '; break; /* xterm */
case 'A': kbd.key = KBD_UP; break; /* kcuu1 vt100 */
case 'B': kbd.key = KBD_DOWN; break; /* kcud1 vt100 */
case 'C': kbd.key = KBD_RIGHT; break; /* kcuf1 vt100 */
case 'D': kbd.key = KBD_LEFT; break; /* kcub1 vt100 */
case 'F': kbd.key = KBD_END; break; /* kend xterm */
case 'H': kbd.key = KBD_HOME; break; /* khome xterm */
case 'I': kbd.key = KBD_TAB; break; /* xterm */
case 'M': kbd.key = KBD_ENTER; break; /* kent vt100 */
/* FIXME: xterm generates ESC O 2 P for Shift-PF1 */
case 'P': kbd.key = KBD_F1; break; /* kf1 vt100 */
case 'Q': kbd.key = KBD_F2; break; /* kf2 vt100 */
case 'R': kbd.key = KBD_F3; break; /* kf3 vt100 */
case 'S': kbd.key = KBD_F4; break; /* kf4 vt100 */
case 'X': kbd.key = '='; break; /* xterm */
case 'j': case 'k': case 'l': case 'm': /* *+,- xterm */
case 'n': case 'o': case 'p': case 'q': /* ./01 xterm */
case 'r': case 's': case 't': case 'u': /* 2345 xterm */
case 'v': case 'w': case 'x': case 'y': /* 6789 xterm */
kbd.key = c - 'p' + '0'; break;
}
if (kbd.key != KBD_UNDEF)
copy_struct(&ev->info.keyboard, &kbd);
return 3; /* even if we didn't recognize it */
}
开发者ID:Efreak,项目名称:elinks,代码行数:54,代码来源:kbd.c
示例15: port_set_data_2
BIF_RETTYPE port_set_data_2(BIF_ALIST_2)
{
/*
* This is not a signal. See comment above.
*/
erts_aint_t data;
Port* prt;
prt = data_lookup_port(BIF_P, BIF_ARG_1);
if (!prt)
BIF_ERROR(BIF_P, BADARG);
if (is_immed(BIF_ARG_2)) {
data = (erts_aint_t) BIF_ARG_2;
ASSERT((data & 0x3) != 0);
}
else {
ErtsPortDataHeap *pdhp;
Uint hsize;
Eterm *hp;
hsize = size_object(BIF_ARG_2);
pdhp = erts_alloc(ERTS_ALC_T_PORT_DATA_HEAP,
sizeof(ErtsPortDataHeap) + (hsize-1)*sizeof(Eterm));
hp = &pdhp->heap[0];
pdhp->off_heap.first = NULL;
pdhp->off_heap.overhead = 0;
pdhp->hsize = hsize;
pdhp->data = copy_struct(BIF_ARG_2, hsize, &hp, &pdhp->off_heap);
data = (erts_aint_t) pdhp;
ASSERT((data & 0x3) == 0);
}
data = erts_smp_atomic_xchg_wb(&prt->data, data);
if (data == (erts_aint_t)NULL) {
/* Port terminated by racing thread */
data = erts_smp_atomic_xchg_wb(&prt->data, data);
ASSERT(data != (erts_aint_t)NULL);
cleanup_old_port_data(data);
BIF_ERROR(BIF_P, BADARG);
}
cleanup_old_port_data(data);
BIF_RET(am_true);
}
开发者ID:crownedgrouse,项目名称:otp,代码行数:45,代码来源:erl_bif_port.c
示例16: port_get_data_1
BIF_RETTYPE port_get_data_1(BIF_ALIST_1)
{
BIF_RETTYPE res;
Port* prt;
Eterm portid = BIF_ARG_1;
prt = id_or_name2port(BIF_P, portid);
if (!prt) {
BIF_ERROR(BIF_P, BADARG);
}
if (prt->bp == NULL) { /* MUST be CONST! */
res = prt->data;
} else {
Eterm* hp = HAlloc(BIF_P, prt->bp->used_size);
res = copy_struct(prt->data, prt->bp->used_size, &hp, &MSO(BIF_P));
}
erts_smp_port_unlock(prt);
BIF_RET(res);
}
开发者ID:Korn1699,项目名称:otp,代码行数:19,代码来源:erl_bif_port.c
示例17: insert_node_referrer
static void
insert_node_referrer(ReferredNode *referred_node, int type, Eterm id)
{
NodeReferrer *nrp;
for(nrp = referred_node->referrers; nrp; nrp = nrp->next)
if(EQ(id, nrp->id))
break;
if(!nrp) {
nrp = (NodeReferrer *) erts_alloc(ERTS_ALC_T_NC_TMP,
sizeof(NodeReferrer));
nrp->next = referred_node->referrers;
referred_node->referrers = nrp;
if(IS_CONST(id))
nrp->id = id;
else {
Uint *hp = &nrp->id_heap[0];
ASSERT(is_big(id) || is_tuple(id));
nrp->id = copy_struct(id, size_object(id), &hp, NULL);
}
nrp->heap_ref = 0;
nrp->link_ref = 0;
nrp->monitor_ref = 0;
nrp->ets_ref = 0;
nrp->bin_ref = 0;
nrp->timer_ref = 0;
nrp->system_ref = 0;
}
switch (type) {
case HEAP_REF: nrp->heap_ref++; break;
case LINK_REF: nrp->link_ref++; break;
case ETS_REF: nrp->ets_ref++; break;
case BIN_REF: nrp->bin_ref++; break;
case MONITOR_REF: nrp->monitor_ref++; break;
case TIMER_REF: nrp->timer_ref++; break;
case SYSTEM_REF: nrp->system_ref++; break;
default: ASSERT(0);
}
}
开发者ID:ask,项目名称:erlang-otp,代码行数:41,代码来源:erl_node_tables.c
示例18: insert_dist_referrer
static void
insert_dist_referrer(ReferredDist *referred_dist,
int type,
Eterm id,
Uint creation)
{
DistReferrer *drp;
for(drp = referred_dist->referrers; drp; drp = drp->next)
if(id == drp->id && (type == CTRL_REF
|| creation == drp->creation))
break;
if(!drp) {
drp = (DistReferrer *) erts_alloc(ERTS_ALC_T_NC_TMP,
sizeof(DistReferrer));
drp->next = referred_dist->referrers;
referred_dist->referrers = drp;
if(IS_CONST(id))
drp->id = id;
else {
Uint *hp = &drp->id_heap[0];
ASSERT(is_tuple(id));
drp->id = copy_struct(id, size_object(id), &hp, NULL);
}
drp->creation = creation;
drp->heap_ref = 0;
drp->node_ref = 0;
drp->ctrl_ref = 0;
drp->system_ref = 0;
}
switch (type) {
case NODE_REF: drp->node_ref++; break;
case CTRL_REF: drp->ctrl_ref++; break;
case HEAP_REF: drp->heap_ref++; break;
case SYSTEM_REF: drp->system_ref++; break;
default: ASSERT(0);
}
}
开发者ID:JamesGreenhalgh,项目名称:otp,代码行数:40,代码来源:erl_node_tables.c
示例19: copy_object
/*
* Copy object "obj" to process p.
*/
Eterm
copy_object(Eterm obj, Process* to)
{
Uint size = size_object(obj);
Eterm* hp = HAlloc(to, size);
Eterm res;
#ifdef USE_VM_PROBES
if (DTRACE_ENABLED(copy_object)) {
DTRACE_CHARBUF(proc_name, 64);
erts_snprintf(proc_name, sizeof(proc_name), "%T", to->common.id);
DTRACE2(copy_object, proc_name, size);
}
#endif
res = copy_struct(obj, size, &hp, &to->off_heap);
#ifdef DEBUG
if (eq(obj, res) == 0) {
erl_exit(ERTS_ABORT_EXIT, "copy not equal to source\n");
}
#endif
return res;
}
开发者ID:Airon2014,项目名称:otp,代码行数:26,代码来源:copy.c
示例20: sort_and_display_entries
static void
sort_and_display_entries(FSP_DIR *dir, const unsigned char dircolor[])
{
/* fsp_readdir_native in fsplib 0.9 and earlier requires
* the third parameter to point to a non-null pointer
* even though it does not dereference that pointer
* and overwrites it with another one anyway.
* http://sourceforge.net/tracker/index.php?func=detail&aid=1875210&group_id=93841&atid=605738
* Work around the bug by using non-null &tmp.
* Nothing will actually read or write tmp. */
FSP_RDENTRY fentry, tmp, *table = NULL;
FSP_RDENTRY *fresult = &tmp;
int size = 0;
int i;
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
FSP_RDENTRY *new_table;
if (!fresult) break;
if (!strcmp(fentry.name, "."))
continue;
new_table = mem_realloc(table, (size + 1) * sizeof(*table));
if (!new_table)
continue;
table = new_table;
copy_struct(&table[size], &fentry);
size++;
}
/* If size==0, then table==NULL. According to ISO/IEC 9899:1999
* 7.20.5p1, the NULL must not be given to qsort. */
if (size > 0)
qsort(table, size, sizeof(*table), compare);
for (i = 0; i < size; i++) {
display_entry(&table[i], dircolor);
}
}
开发者ID:Efreak,项目名称:elinks,代码行数:37,代码来源:fsp.c
注:本文中的copy_struct函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论