您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xnmalloc函数代码示例

51自学网 2021-06-03 11:50:24
  C++
这篇教程C++ xnmalloc函数代码示例写得很实用,希望能帮到您。

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

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

示例1: test_insert_any_remove_reverse

/* Inserts strings into a set in each possible order, then   removes them in reverse order, up to a specified maximum   size. */static voidtest_insert_any_remove_reverse (void){  const int max_elems = 7;  int cnt;  for (cnt = 0; cnt <= max_elems; cnt++)    {      int *insertions, *deletions;      unsigned int permutation_cnt;      int i;      insertions = xnmalloc (cnt, sizeof *insertions);      deletions = xnmalloc (cnt, sizeof *deletions);      for (i = 0; i < cnt; i++)        insertions[i] = i;      for (permutation_cnt = 0;           permutation_cnt == 0 || next_permutation (insertions, cnt);           permutation_cnt++)        {          memcpy (deletions, insertions, sizeof *insertions * cnt);          reverse (deletions, cnt);          test_insert_delete (insertions, deletions, cnt);        }      check (permutation_cnt == factorial (cnt));      free (insertions);      free (deletions);    }}
开发者ID:student-t,项目名称:PSPP,代码行数:35,


示例2: xstring_init

struct _xstring* xstring_init(void){	struct _xstring *p = (struct _xstring *) xnmalloc(sizeof(struct _xstring));	bzero(p, sizeof(struct _xstring));	p->cur_size		= INIT_STRING_LENGTH;	p->content		= (char *) xnmalloc(p->cur_size * sizeof(char));	p->keycode		= (KeyCode *) xnmalloc(p->cur_size * sizeof(KeyCode));	p->keycode_modifiers	= (int *) xnmalloc(p->cur_size * sizeof(int));	bzero(p->content, p->cur_size * sizeof(char));	bzero(p->keycode, p->cur_size * sizeof(KeyCode));	bzero(p->keycode_modifiers, p->cur_size * sizeof(int));	// Functions mapping	p->clear		= xstring_clear;	p->is_space_last	= xstring_is_space_last;	p->set_key_code		= xstring_set_key_code;	p->set_content		= xstring_set_content;	p->changecase_content = xstring_changecase_content;	p->add_symbol		= xstring_add_symbol;	p->del_symbol		= xstring_del_symbol;	p->uninit		= xstring_uninit;	return p;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:26,


示例3: test_random_sequence

/* Inserts and removes strings in a set, in random order. */static voidtest_random_sequence (void){  const int max_elems = 64;  const int max_trials = 8;  int cnt;  for (cnt = 0; cnt <= max_elems; cnt += 2)    {      int *insertions, *deletions;      int trial;      int i;      insertions = xnmalloc (cnt, sizeof *insertions);      deletions = xnmalloc (cnt, sizeof *deletions);      for (i = 0; i < cnt; i++)        insertions[i] = i;      for (i = 0; i < cnt; i++)        deletions[i] = i;      for (trial = 0; trial < max_trials; trial++)        {          random_shuffle (insertions, cnt, sizeof *insertions);          random_shuffle (deletions, cnt, sizeof *deletions);          test_insert_delete (insertions, deletions, cnt);        }      free (insertions);      free (deletions);    }}
开发者ID:student-t,项目名称:PSPP,代码行数:33,


示例4: xkeymap_init

struct _xkeymap* xkeymap_init(void){	struct _xkeymap *p = (struct _xkeymap *) xnmalloc(sizeof(struct _xkeymap));	bzero(p, sizeof(struct _xkeymap));	p->latin_group = 0;	p->latin_group_mask = 0;				// Define latin group mask		p->alphabet = xnmalloc(1);		if (!xkeymap_init_keymaps(p))		return NULL;		if (!xkeymap_locale_create(p))		return NULL;		if (!xkeymap_define_latin_group(p))		return NULL;		p->get_ascii = xkeymap_get_ascii;	p->get_cur_ascii_char = xkeymap_get_cur_ascii_char;	p->convert_text_to_ascii = xkeymap_convert_text_to_ascii;	p->store_keymaps = xkeymap_store_keymaps;	p->char_to_keycode = xkeymap_char_to_keycode;	return p;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:26,


示例5: relation_transpose

voidrelation_transpose (relation *R_arg, relation_node n){  relation r = *R_arg;  /* The result. */  relation new_R = xnmalloc (n, sizeof *new_R);  /* END_R[I] -- next entry of NEW_R[I]. */  relation end_R = xnmalloc (n, sizeof *end_R);  /* NEDGES[I] -- total size of NEW_R[I]. */  size_t *nedges = xcalloc (n, sizeof *nedges);  relation_node i;  relation_node j;  if (trace_flag & trace_sets)    {      fputs ("relation_transpose: input/n", stderr);      relation_print (r, n, stderr);    }  /* Count. */  for (i = 0; i < n; i++)    if (r[i])      for (j = 0; r[i][j] != END_NODE; ++j)        ++nedges[r[i][j]];  /* Allocate. */  for (i = 0; i < n; i++)    {      relation_node *sp = NULL;      if (nedges[i] > 0)        {          sp = xnmalloc (nedges[i] + 1, sizeof *sp);          sp[nedges[i]] = END_NODE;        }      new_R[i] = sp;      end_R[i] = sp;    }  /* Store. */  for (i = 0; i < n; i++)    if (r[i])      for (j = 0; r[i][j] != END_NODE; ++j)        *end_R[r[i][j]]++ = i;  free (nedges);  free (end_R);  /* Free the input: it is replaced with the result. */  for (i = 0; i < n; i++)    free (r[i]);  free (r);  if (trace_flag & trace_sets)    {      fputs ("relation_transpose: output/n", stderr);      relation_print (new_R, n, stderr);    }  *R_arg = new_R;}
开发者ID:AnotherView,项目名称:bison,代码行数:60,


示例6: xkeymap_store_keymaps

static void xkeymap_store_keymaps(struct _xkeymap *p, int group){	int min_keycode, max_keycode, keysyms_per_keycode;	KeySym *keymap;	XDisplayKeycodes (main_window->display, &min_keycode, &max_keycode);	keymap = XGetKeyboardMapping (main_window->display, min_keycode, max_keycode - min_keycode + 1, &keysyms_per_keycode);		p->min_keycode = min_keycode;	p->max_keycode = max_keycode;	if (p->total_key_arrays < group) 		p->total_key_arrays = group;		p->alphabet = xnrealloc(p->alphabet, (group + 1) * sizeof(struct _xkeymap_alpha));	p->alphabet[group] = xnmalloc((max_keycode + 1) * sizeof(struct _xkeymap_alpha));			for (int i = min_keycode; i <= max_keycode; i++) 	{		int  j;		p->alphabet[group][i].lower_sym = xnmalloc(1);		p->alphabet[group][i].lower_sym[0] = NULLSYM;		p->alphabet[group][i].upper_sym = xnmalloc(1);		p->alphabet[group][i].upper_sym[0] = NULLSYM;		for (j = group*2; j <= group*2 + 1; j++) 		{			KeySym ks = keymap[j];			int groups[4] = {0x00000000, 0x00002000, 0x00004000, 0x00006000};			if (ks != NoSymbol)			{				XEvent event = create_basic_event();				event.xkey.keycode		= i;				event.xkey.state		= groups[group];				if (j == group*2 + 1)					event.xkey.state |= ShiftMask;				int nbytes;    			char str[256+1];				nbytes = XLookupString ((XKeyEvent *) &event, str, 256, &ks, NULL);								if (nbytes > 0)				{					if (j == group*2)					{						p->alphabet[group][i].lower_sym = xnmalloc(nbytes+1);						strncpy(p->alphabet[group][i].lower_sym, str, nbytes+1);						p->alphabet[group][i].lower_sym[nbytes] = NULLSYM;					}					else					{						p->alphabet[group][i].upper_sym = xnmalloc(nbytes+1);						strncpy(p->alphabet[group][i].upper_sym, str, nbytes+1);						p->alphabet[group][i].upper_sym[nbytes] = NULLSYM;					}				}			}		}		keymap += keysyms_per_keycode;    }}
开发者ID:voidptr,项目名称:xneur-option,代码行数:58,


示例7: readtokens

size_treadtokens (FILE *stream,            size_t projected_n_tokens,            const char *delim,            size_t n_delim,            char ***tokens_out,            size_t **token_lengths){  token_buffer tb, *token = &tb;  char **tokens;  size_t *lengths;  size_t sz;  size_t n_tokens;  if (projected_n_tokens == 0)    projected_n_tokens = 64;  else    projected_n_tokens++;       /* add one for trailing NULL pointer */  sz = projected_n_tokens;  tokens = xnmalloc (sz, sizeof *tokens);  lengths = xnmalloc (sz, sizeof *lengths);  n_tokens = 0;  init_tokenbuffer (token);  for (;;)    {      char *tmp;      size_t token_length = readtoken (stream, delim, n_delim, token);      if (n_tokens >= sz)        {          tokens = x2nrealloc (tokens, &sz, sizeof *tokens);          lengths = xnrealloc (lengths, sz, sizeof *lengths);        }      if (token_length == (size_t) -1)        {          /* don't increment n_tokens for NULL entry */          tokens[n_tokens] = NULL;          lengths[n_tokens] = 0;          break;        }      tmp = xnmalloc (token_length + 1, sizeof *tmp);      lengths[n_tokens] = token_length;      tokens[n_tokens] = memcpy (tmp, token->buffer, token_length + 1);      n_tokens++;    }  free (token->buffer);  *tokens_out = tokens;  if (token_lengths != NULL)    *token_lengths = lengths;  else    free (lengths);  return n_tokens;}
开发者ID:SamB,项目名称:debian-coreutils,代码行数:56,


示例8: allocate_storage

static voidallocate_storage (void){  allocate_itemsets ();  shiftset = xnmalloc (nsyms, sizeof *shiftset);  redset = xnmalloc (nrules, sizeof *redset);  state_hash_new ();  shift_symbol = xnmalloc (nsyms, sizeof *shift_symbol);}
开发者ID:a170785,项目名称:buildroot,代码行数:10,


示例9: nonterminals_reduce

static voidnonterminals_reduce (void){  /* Map the nonterminals to their new index: useful first, useless     afterwards.  Kept for later report.  */  symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);  symbol_number n = ntokens;  symbol_number i;  for (i = ntokens; i < nsyms; i++)    if (bitset_test (V, i))      nontermmap[i - ntokens] = n++;  for (i = ntokens; i < nsyms; i++)    if (!bitset_test (V, i))      {        nontermmap[i - ntokens] = n++;        if (symbols[i]->status != used)          complain (&symbols[i]->location, Wother,                    _("nonterminal useless in grammar: %s"),                    symbols[i]->tag);      }  /* Shuffle elements of tables indexed by symbol number.  */  {    symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);    for (i = ntokens; i < nsyms; i++)      symbols[i]->number = nontermmap[i - ntokens];    for (i = ntokens; i < nsyms; i++)      symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];    for (i = ntokens; i < nsyms; i++)      symbols[i] = symbols_sorted[i - ntokens];    free (symbols_sorted);  }  {    rule_number r;    for (r = 0; r < nrules; ++r)      {        item_number *rhsp;        for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)          if (ISVAR (*rhsp))            *rhsp =  symbol_number_as_item_number (nontermmap[*rhsp                                                              - ntokens]);      }    accept->number = nontermmap[accept->number - ntokens];  }  nsyms -= nuseless_nonterminals;  nvars -= nuseless_nonterminals;  free (nontermmap);}
开发者ID:epicgithub,项目名称:VisualBison,代码行数:54,


示例10: derives_compute

voidderives_compute (void){  symbol_number i;  rule_number r;  rule **q;  /* DSET[NTERM - NTOKENS] -- A linked list of the numbers of the rules     whose LHS is NTERM.  */  rule_list **dset = xcalloc (nvars, sizeof *dset);  /* DELTS[RULE] -- There are NRULES rule number to attach to nterms.     Instead of performing NRULES allocations for each, have an array     indexed by rule numbers.  */  rule_list *delts = xnmalloc (nrules, sizeof *delts);  for (r = nrules - 1; r >= 0; --r)    {      symbol_number lhs = rules[r].lhs->number;      rule_list *p = &delts[r];      /* A new LHS is found.  */      p->next = dset[lhs - ntokens];      p->value = &rules[r];      dset[lhs - ntokens] = p;    }  /* DSET contains what we need under the form of a linked list.  Make     it a single array.  */  derives = xnmalloc (nvars, sizeof *derives);  q = xnmalloc (nvars + nrules, sizeof *q);  for (i = ntokens; i < nsyms; i++)    {      rule_list *p = dset[i - ntokens];      derives[i - ntokens] = q;      while (p)        {          *q++ = p->value;          p = p->next;        }      *q++ = NULL;    }  if (trace_flag & trace_sets)    print_derives ();  free (dset);  free (delts);}
开发者ID:AnotherView,项目名称:bison,代码行数:50,


示例11: elog_setoverride

/* sets a pattern to override the severity stated by the program * or application for an error. The pattern is applied to the event text * each time _send() is called. Each override will take some space * so unused ones should be discarded with _rmoverride(). * returns 1 if successfully added to list, or 0 if unable to add. */int elog_setoverride(enum elog_severity severity,	/* severity level */		     char *re_pattern			/* reg exp pattern */ ){     int r;     char errbuf[ELOG_STRLEN];     struct elog_overridedat *over;     elog_checkinit();     /* severity in range? */     if (severity >= ELOG_NSEVERITIES || severity < 0)	  return 0;     over = xnmalloc(sizeof(struct elog_overridedat));     if ((r = regcomp(&over->pattern, re_pattern, (REG_EXTENDED|REG_NOSUB)))) {	  regerror(r, &over->pattern, errbuf, ELOG_STRLEN);	  elog_printf(ERROR, "elog_setoverride() problem with key "		      "pattern: %s/nError is %s/n", re_pattern, errbuf);	  nfree(over);	  return 0;     }     over->severity = severity;     tree_add(elog_override, xnstrdup(re_pattern), over);     return 1;}
开发者ID:SystemGarden,项目名称:habitat,代码行数:33,


示例12: get_file_content

char* get_file_content(const char *file_name){	struct stat sb;	if (stat(file_name, &sb) != 0 || sb.st_size < 0)		return NULL;	FILE *stream = fopen(file_name, "rb");	if (stream == NULL)		return NULL;	unsigned int file_len = sb.st_size;		char *content = (char *) xnmalloc((file_len + 2) * sizeof(char)); // + 1 '/n' + 1 '/0'	if (fread(content, 1, file_len, stream) != file_len)	{		free(content);		fclose(stream);		return NULL;	}	content[file_len] = '/n';	content[file_len + 1] = '/0';	fclose(stream);	return content;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:27,


示例13: test_insert_ordered

/* Inserts strings into a map in ascending order, then delete in ascending   order. */static voidtest_insert_ordered (void){  const int max_elems = 64;  int *values;  struct string_map map;  int i;  string_map_init (&map);  values = xnmalloc (max_elems, sizeof *values);  for (i = 0; i < max_elems; i++)    {      values[i] = i | random_value (i, 4);      string_map_insert_nocopy (&map, xstrdup (make_key (values[i])),                                xstrdup (make_value (values[i])));      check_string_map (&map, values, i + 1);    }  for (i = 0; i < max_elems; i++)    {      string_map_delete (&map, make_key (i));      check_string_map (&map, values + i + 1, max_elems - i - 1);    }  string_map_destroy (&map);  free (values);}
开发者ID:RobertDash,项目名称:pspp,代码行数:27,


示例14: convert_text_to_translit

char* convert_text_to_translit(const char *text){	int i, j, len = strlen(text);	char *trans_text = (char *)xnmalloc((len * 3 + 1) * sizeof(char));	for(i = 0, j = 0; i < len; i++)	{		if (isascii(text[i]))		{			trans_text[j++] = text[i];			continue;		}		const char *new_symbol = get_translit(&text[i]);		for(; i < len - 1; i++)		{			if (isascii(text[i + 1]))				break;			if (get_translit(&text[i + 1]) != NULLSYM)				break;		}		while (*new_symbol != NULLSYM)		{			trans_text[j++] = *new_symbol;			new_symbol++;		}	}	trans_text[j] = NULLSYM;	return trans_text;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:34,


示例15: backtrace_log

void backtrace_log(int retval, const char *fn,		   const char *file, int lineno){	struct backtrace_data *btd;	struct error_frame *ef;	btd = pthread_getspecific(btkey);	if (btd == NULL)		btd = &main_btd;	ef = xnmalloc(sizeof(*ef));	if (ef == NULL)		return;	ef->retval = retval;	ef->lineno = lineno;	ef->fn = fn;	ef->file = file;	write_lock(&btd->lock);	if (btd->inner == NULL)		/* Fire the hook for the inner trace. */		error_hook(ef);	ef->next = btd->inner;	btd->inner = ef;	write_unlock(&btd->lock);}
开发者ID:BhargavKola,项目名称:xenomai-forge,代码行数:30,


示例16: test_insert_any_remove_same

/* Inserts strings into a set in each possible order, then removes them in the   same order, up to a specified maximum size. */static voidtest_insert_any_remove_same (void){  const int max_elems = 7;  int cnt;  for (cnt = 0; cnt <= max_elems; cnt++)    {      int *values;      unsigned int permutation_cnt;      int i;      values = xnmalloc (cnt, sizeof *values);      for (i = 0; i < cnt; i++)        values[i] = i;      for (permutation_cnt = 0;           permutation_cnt == 0 || next_permutation (values, cnt);           permutation_cnt++)        test_insert_delete (values, values, cnt);      check (permutation_cnt == factorial (cnt));      free (values);    }}
开发者ID:student-t,项目名称:PSPP,代码行数:27,


示例17: cre_flg

ER cre_flg(ID flgid, T_CFLG *pk_cflg){	uiflag_t *flag;	if (xnpod_asynch_p())		return EN_CTXID;	if (flgid <= 0 || flgid > uITRON_MAX_MBXID)		return E_ID;	flag = xnmalloc(sizeof(*flag));	if (!flag)		return E_NOMEM;	flgid = xnmap_enter(ui_flag_idmap, flgid, flag);	if (flgid <= 0) {		xnfree(flag);		return E_OBJ;	}	xnsynch_init(&flag->synchbase, XNSYNCH_FIFO, NULL);	flag->id = flgid;	flag->exinf = pk_cflg->exinf;	flag->flgatr = pk_cflg->flgatr;	flag->flgvalue = pk_cflg->iflgptn;	sprintf(flag->name, "flg%d", flgid);	xnregistry_enter(flag->name, flag, &flag->handle, &__flag_pnode.node);	xnarch_memory_barrier();	flag->magic = uITRON_FLAG_MAGIC;	return E_OK;}
开发者ID:JackieXie168,项目名称:xenomai,代码行数:34,


示例18: conflicts_solve

voidconflicts_solve (void){  state_number i;  /* List of lookahead tokens on which we explicitly raise a syntax error.  */  symbol **errors = xnmalloc (ntokens + 1, sizeof *errors);  conflicts = xcalloc (nstates, sizeof *conflicts);  shift_set = bitset_create (ntokens, BITSET_FIXED);  lookahead_set = bitset_create (ntokens, BITSET_FIXED);  obstack_init (&solved_conflicts_obstack);  obstack_init (&solved_conflicts_xml_obstack);  for (i = 0; i < nstates; i++)    {      set_conflicts (states[i], errors);      /* For uniformity of the code, make sure all the states have a valid	 `errs' member.  */      if (!states[i]->errs)	states[i]->errs = errs_new (0, 0);    }  free (errors);}
开发者ID:thomas-moulard,项目名称:urbi-debian,代码行数:25,


示例19: prepare_symbols

static voidprepare_symbols (void){  MUSCLE_INSERT_INT ("tokens_number", ntokens);  MUSCLE_INSERT_INT ("nterms_number", nvars);  MUSCLE_INSERT_INT ("symbols_number", nsyms);  MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);  MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);  muscle_insert_symbol_number_table ("translate",                                     token_translations,                                     token_translations[0],                                     1, max_user_token_number + 1);  /* tname -- token names.  */  {    int i;    /* We assume that the table will be output starting at column 2. */    int j = 2;    struct quoting_options *qo = clone_quoting_options (0);    set_quoting_style (qo, c_quoting_style);    set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);    for (i = 0; i < nsyms; i++)      {        char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);        /* Width of the next token, including the two quotes, the           comma and the space.  */        int width = strlen (cp) + 2;        if (j + width > 75)          {            obstack_sgrow (&format_obstack, "/n ");            j = 1;          }        if (i)          obstack_1grow (&format_obstack, ' ');        obstack_escape (&format_obstack, cp);        free (cp);        obstack_1grow (&format_obstack, ',');        j += width;      }    free (qo);    obstack_sgrow (&format_obstack, " ]b4_null[");    /* Finish table and store. */    muscle_insert ("tname", obstack_finish0 (&format_obstack));  }  /* Output YYTOKNUM. */  {    int i;    int *values = xnmalloc (ntokens, sizeof *values);    for (i = 0; i < ntokens; ++i)      values[i] = symbols[i]->user_token_number;    muscle_insert_int_table ("toknum", values,                             values[0], 1, ntokens);    free (values);  }}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:60,


示例20: msgQCreate

MSG_Q_ID msgQCreate(int nb_msgs, int length, int flags){	static unsigned long msgq_ids;	wind_msgq_t *queue;	xnflags_t bflags = 0;	int i, msg_size;	char *msgs_mem;	spl_t s;	check_NOT_ISR_CALLABLE(return 0);	error_check(nb_msgs <= 0, S_msgQLib_INVALID_QUEUE_TYPE, return 0);	error_check(flags & ~WIND_MSG_Q_OPTION_MASK,		    S_msgQLib_INVALID_QUEUE_TYPE, return 0);	error_check(length < 0, S_msgQLib_INVALID_MSG_LENGTH, return 0);	msgs_mem = xnmalloc(sizeof(wind_msgq_t) +			    nb_msgs * (sizeof(wind_msg_t) + length));	error_check(msgs_mem == NULL, S_memLib_NOT_ENOUGH_MEMORY, return 0);	queue = (wind_msgq_t *)msgs_mem;	msgs_mem += sizeof(wind_msgq_t);	queue->magic = WIND_MSGQ_MAGIC;	queue->msg_length = length;	queue->free_list = NULL;	initq(&queue->msgq);	inith(&queue->rlink);	queue->rqueue = &wind_get_rholder()->msgQq;	/* init of the synch object : */	if (flags & MSG_Q_PRIORITY)		bflags |= XNSYNCH_PRIO;	xnsynch_init(&queue->synchbase, bflags, NULL);	msg_size = sizeof(wind_msg_t) + length;	for (i = 0; i < nb_msgs; ++i, msgs_mem += msg_size)		free_msg(queue, (wind_msg_t *)msgs_mem);	xnlock_get_irqsave(&nklock, s);	appendq(queue->rqueue, &queue->rlink);	xnlock_put_irqrestore(&nklock, s);	sprintf(queue->name, "mq%lu", msgq_ids++);	if (xnregistry_enter(queue->name, queue,			     &queue->handle, &msgq_pnode)) {		wind_errnoset(S_objLib_OBJ_ID_ERROR);		msgQDelete((MSG_Q_ID)queue);		return 0;	}	return (MSG_Q_ID)queue;}
开发者ID:chrmorais,项目名称:miniemc2,代码行数:59,


示例21: prepare_symbols

static voidprepare_symbols (void){  MUSCLE_INSERT_BOOL ("token_table", token_table_flag);  MUSCLE_INSERT_INT ("tokens_number", ntokens);  MUSCLE_INSERT_INT ("nterms_number", nvars);  MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);  MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);  muscle_insert_symbol_number_table ("translate",				     token_translations,				     token_translations[0],				     1, max_user_token_number + 1);  /* tname -- token names.  */  {    int i;    /* We assume that the table will be output starting at column 2. */    int j = 2;    for (i = 0; i < nsyms; i++)      {	char const *cp = quotearg_style (c_quoting_style, symbols[i]->tag);	/* Width of the next token, including the two quotes, the	   comma and the space.  */	int width = strlen (cp) + 2;	if (j + width > 75)	  {	    obstack_sgrow (&format_obstack, "/n ");	    j = 1;	  }	if (i)	  obstack_1grow (&format_obstack, ' ');	MUSCLE_OBSTACK_SGROW (&format_obstack, cp);	obstack_1grow (&format_obstack, ',');	j += width;      }    /* Add a NULL entry to list of tokens (well, 0, as NULL might not be       defined).  */    obstack_sgrow (&format_obstack, " 0");    /* Finish table and store. */    obstack_1grow (&format_obstack, 0);    muscle_insert ("tname", obstack_finish (&format_obstack));  }  /* Output YYTOKNUM. */  {    int i;    int *values = xnmalloc (ntokens, sizeof *values);    for (i = 0; i < ntokens; ++i)      values[i] = symbols[i]->user_token_number;    muscle_insert_int_table ("toknum", values,			     values[0], 1, ntokens);    free (values);  }}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:58,


示例22: make_dynvec

struct dynvec *make_dynvec (int n){  struct dynvec *dv = xmalloc (sizeof *dv);  dv->dv_vec = xnmalloc (n, sizeof *dv->dv_vec);  dv->dv_capacity = n;  dv->dv_fill = 0;  return dv;}
开发者ID:duongbaoduy,项目名称:emacs-space,代码行数:9,


示例23: lower_word

char* lower_word(const char *word, int len){	char *ret = (char *) xnmalloc(len + 1);	int i;	for (i = 0; i < len; i++)		ret[i] = tolower(word[i]);	ret[len] = NULLSYM;	return ret;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:10,


示例24: allocate_itemsets

static voidallocate_itemsets (void){  symbol_number i;  rule_number r;  item_number *rhsp;  /* Count the number of occurrences of all the symbols in RITEMS.     Note that useless productions (hence useless nonterminals) are     browsed too, hence we need to allocate room for _all_ the     symbols.  */  size_t count = 0;  size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,				  sizeof *symbol_count);  for (r = 0; r < nrules; ++r)    for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)      {	count++;	symbol_count[*rhsp]++;      }  /* See comments before new_itemsets.  All the vectors of items     live inside KERNEL_ITEMS.  The number of active items after     some symbol S cannot be more than the number of times that S     appears as an item, which is SYMBOL_COUNT[S].     We allocate that much space for each symbol.  */  kernel_base = xnmalloc (nsyms, sizeof *kernel_base);  kernel_items = xnmalloc (count, sizeof *kernel_items);  count = 0;  for (i = 0; i < nsyms; i++)    {      kernel_base[i] = kernel_items + count;      count += symbol_count[i];    }  free (symbol_count);  kernel_size = xnmalloc (nsyms, sizeof *kernel_size);}
开发者ID:a170785,项目名称:buildroot,代码行数:41,


示例25: test_insert_any_remove_any

/* Inserts strings into a map in each possible order, then removes them in each   possible order, up to a specified maximum size. */static voidtest_insert_any_remove_any (void){  const int basis = 0;  const int max_elems = 5;  int cnt;  for (cnt = 0; cnt <= max_elems; cnt++)    {      int *insertions, *deletions;      unsigned int ins_perm_cnt;      int i;      insertions = xnmalloc (cnt, sizeof *insertions);      deletions = xnmalloc (cnt, sizeof *deletions);      for (i = 0; i < cnt; i++)        insertions[i] = i | random_value (i, basis);      for (ins_perm_cnt = 0;           ins_perm_cnt == 0 || next_permutation (insertions, cnt);           ins_perm_cnt++)        {          unsigned int del_perm_cnt;          int i;          for (i = 0; i < cnt; i++)            deletions[i] = i | random_value (i, basis);          for (del_perm_cnt = 0;               del_perm_cnt == 0 || next_permutation (deletions, cnt);               del_perm_cnt++)            test_insert_delete (insertions, deletions, cnt);          check (del_perm_cnt == factorial (cnt));        }      check (ins_perm_cnt == factorial (cnt));      free (insertions);      free (deletions);    }}
开发者ID:RobertDash,项目名称:pspp,代码行数:43,


示例26: linreg_alloc

/*  Allocate a linreg and return a pointer to it. n is the number of  cases, p is the number of independent variables. */linreg *linreg_alloc (const struct variable *depvar, const struct variable **indep_vars,	      double n, size_t p){  linreg *c;  size_t i;  c = xmalloc (sizeof (*c));  c->depvar = depvar;  c->indep_vars = xnmalloc (p, sizeof (*indep_vars));  c->dependent_column = p;  for (i = 0; i < p; i++)    {      c->indep_vars[i] = indep_vars[i];    }  c->indep_means = gsl_vector_alloc (p);  c->indep_std = gsl_vector_alloc (p);  c->ss_indeps = gsl_vector_alloc (p);	/* Sums of squares for the					   model parameters.					 */  c->n_obs = n;  c->n_indeps = p;  c->n_coeffs = p;  c->coeff = xnmalloc (p, sizeof (*c->coeff));  c->cov = gsl_matrix_calloc (c->n_coeffs + 1, c->n_coeffs + 1);  c->dft = n - 1;  c->dfm = p;  c->dfe = c->dft - c->dfm;  c->intercept = 0.0;  c->depvar_mean = 0.0;  c->depvar_std = 0.0;  /*     Default settings.   */  c->method = LINREG_SWEEP;  c->pred = NULL;  c->resid = NULL;  return c;}
开发者ID:RobertDash,项目名称:pspp,代码行数:45,


示例27: xwindow_init

struct _xwindow* xwindow_init(void){	struct _xwindow *p = (struct _xwindow *) xnmalloc(sizeof(struct _xwindow));	bzero(p, sizeof(struct _xwindow));	// Function mapping	p->create	= xwindow_create;	p->destroy	= xwindow_destroy;	p->move_window	= xwindow_move_window;	return p;}
开发者ID:voidptr,项目名称:xneur-option,代码行数:12,



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


C++ xo_emit函数代码示例
C++ xnlock_put_irqrestore函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。