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

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

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

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

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

示例1: load_all_part_state

/* * load_all_part_state - load the partition state from file, recover on *	slurmctld restart. execute this after loading the configuration *	file data. * NOTE: READ lock_slurmctld config before entry */int load_all_part_state(void){	char *part_name = NULL, *allow_groups = NULL, *nodes = NULL;	char *state_file, *data = NULL;	uint32_t max_time, default_time, max_nodes, min_nodes;	uint32_t grace_time = 0;	time_t time;	uint16_t def_part_flag, flags, hidden, root_only;	uint16_t max_share, preempt_mode, priority, state_up;	struct part_record *part_ptr;	uint32_t data_size = 0, name_len;	int data_allocated, data_read = 0, error_code = 0, part_cnt = 0;	int state_fd;	Buf buffer;	char *ver_str = NULL;	char* allow_alloc_nodes = NULL;	uint16_t protocol_version = (uint16_t)NO_VAL;	char* alternate = NULL;	/* read the file */	lock_state_files();	state_fd = _open_part_state_file(&state_file);	if (state_fd < 0) {		info("No partition state file (%s) to recover",		     state_file);		error_code = ENOENT;	} else {		data_allocated = BUF_SIZE;		data = xmalloc(data_allocated);		while (1) {			data_read = read(state_fd, &data[data_size],					 BUF_SIZE);			if (data_read < 0) {				if  (errno == EINTR)					continue;				else {					error("Read error on %s: %m",						state_file);					break;				}			} else if (data_read == 0)     /* eof */				break;			data_size      += data_read;			data_allocated += data_read;			xrealloc(data, data_allocated);		}		close(state_fd);	}	xfree(state_file);	unlock_state_files();	buffer = create_buf(data, data_size);	safe_unpackstr_xmalloc( &ver_str, &name_len, buffer);	debug3("Version string in part_state header is %s", ver_str);	if(ver_str) {		if (!strcmp(ver_str, PART_STATE_VERSION)) {			protocol_version = SLURM_PROTOCOL_VERSION;		} else if(!strcmp(ver_str, PART_2_1_STATE_VERSION)) {			protocol_version = SLURM_2_1_PROTOCOL_VERSION;		}	}	if (protocol_version == (uint16_t)NO_VAL) {		error("**********************************************************");		error("Can not recover partition state, data version incompatible");		error("**********************************************************");		xfree(ver_str);		free_buf(buffer);		return EFAULT;	}	xfree(ver_str);	safe_unpack_time(&time, buffer);	while (remaining_buf(buffer) > 0) {		if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {			safe_unpackstr_xmalloc(&part_name, &name_len, buffer);			safe_unpack32(&grace_time, buffer);			safe_unpack32(&max_time, buffer);			safe_unpack32(&default_time, buffer);			safe_unpack32(&max_nodes, buffer);			safe_unpack32(&min_nodes, buffer);			safe_unpack16(&flags,        buffer);			safe_unpack16(&max_share,    buffer);			safe_unpack16(&preempt_mode, buffer);			safe_unpack16(&priority,     buffer);			if (priority > part_max_priority)				part_max_priority = priority;			safe_unpack16(&state_up, buffer);			safe_unpackstr_xmalloc(&allow_groups,					       &name_len, buffer);//.........这里部分代码省略.........
开发者ID:lipari,项目名称:slurm,代码行数:101,


示例2: _job_modify

//.........这里部分代码省略.........						}						if (env_ptr[i] == '//') {							i++;						}					}				} else if (env_ptr[i+1] == '/'') {					for (i+=2; ; i++) {						if (env_ptr[i] == '/0') {							error("wiki: setting job %u "							      "invalid environment "							      "variables: %s",					 		     jobid, env_ptr);							return EINVAL;						}						if (env_ptr[i] == '/'') {							i++;							break;						}						if (env_ptr[i] == '//') {							i++;						}					}				}			}			if (isspace(env_ptr[i]) || (env_ptr[i] == ',')) {				if (!have_equal) {					error("wiki: setting job %u invalid "					      "environment variables: %s",					      jobid, env_ptr);					return EINVAL;				}				old_sep[0] = env_ptr[i];				env_ptr[i] = '/0';				xrealloc(job_ptr->details->env_sup,					 sizeof(char *) *					 (job_ptr->details->env_cnt+1));				job_ptr->details->env_sup						[job_ptr->details->env_cnt++] =						xstrdup(&env_ptr[begin]);				info("wiki: for job %u add env: %s",				     jobid, &env_ptr[begin]);				env_ptr[i] = old_sep[0];				if (isspace(old_sep[0]))					break;				begin = i + 1;				have_equal = false;			}		}	}	if (new_time_limit) {		time_t old_time = job_ptr->time_limit;		job_ptr->time_limit = new_time_limit;		info("wiki: change job %u time_limit to %u",			jobid, new_time_limit);		/* Update end_time based upon change		 * to preserve suspend time info */		job_ptr->end_time = job_ptr->end_time +				((job_ptr->time_limit -				  old_time) * 60);		last_job_update = now;	}	if (bank_ptr &&	    (update_job_account("wiki", job_ptr, bank_ptr) != SLURM_SUCCESS)) {		return EINVAL;
开发者ID:A1ve5,项目名称:slurm,代码行数:67,


示例3: process_files

//.........这里部分代码省略.........			case 'T':				if (substituted) break;				/* Fall through */			/* Branch to label */			case 'b':				if (!sed_cmd->string) goto discard_commands;				else sed_cmd = branch_to(sed_cmd->string);				break;			/* Transliterate characters */			case 'y':			{				int i, j;				for (i = 0; pattern_space[i]; i++) {					for (j = 0; sed_cmd->string[j]; j += 2) {						if (pattern_space[i] == sed_cmd->string[j]) {							pattern_space[i] = sed_cmd->string[j + 1];							break;						}					}				}				break;			}			case 'g':	/* Replace pattern space with hold space */				free(pattern_space);				pattern_space = xstrdup(G.hold_space ? G.hold_space : "");				break;			case 'G':	/* Append newline and hold space to pattern space */			{				int pattern_space_size = 2;				int hold_space_size = 0;				if (pattern_space)					pattern_space_size += strlen(pattern_space);				if (G.hold_space)					hold_space_size = strlen(G.hold_space);				pattern_space = xrealloc(pattern_space,						pattern_space_size + hold_space_size);				if (pattern_space_size == 2)					pattern_space[0] = 0;				strcat(pattern_space, "/n");				if (G.hold_space)					strcat(pattern_space, G.hold_space);				last_gets_char = '/n';				break;			}			case 'h':	/* Replace hold space with pattern space */				free(G.hold_space);				G.hold_space = xstrdup(pattern_space);				break;			case 'H':	/* Append newline and pattern space to hold space */			{				int hold_space_size = 2;				int pattern_space_size = 0;				if (G.hold_space)					hold_space_size += strlen(G.hold_space);				if (pattern_space)					pattern_space_size = strlen(pattern_space);				G.hold_space = xrealloc(G.hold_space,						hold_space_size + pattern_space_size);				if (hold_space_size == 2)					*G.hold_space = 0;				strcat(G.hold_space, "/n");				if (pattern_space)					strcat(G.hold_space, pattern_space);				break;			}			case 'x': /* Exchange hold and pattern space */			{				char *tmp = pattern_space;				pattern_space = G.hold_space ? : xzalloc(1);				last_gets_char = '/n';				G.hold_space = tmp;				break;			}			}		}	}	/*	 * exit point from sedding...	 */ discard_commands:	/* we will print the line unless we were told to be quiet ('-n')	   or if the line was suppressed (ala 'd'elete) */	if (!G.be_quiet)		sed_puts(pattern_space, last_gets_char);	/* Delete and such jump here. */ discard_line:	flush_append();	free(pattern_space);	goto again;}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:101,


示例4: read_lines

//.........这里部分代码省略.........                continue;            }            {                size_t new_linepos = linepos + 1;                if (c == '/t') {                    new_linepos += 7;                    new_linepos &= (~7);                }                if (new_linepos >= w)                    break;                linepos = new_linepos;            }            /* ok, we will eat this char */            readpos++;            if (c == '/n') {                terminated = 1;                linepos = 0;                break;            }            /* NUL is substituted by '/n'! */            if (c == '/0') c = '/n';            *p++ = c;            *p = '/0';        } /* end of "read chars until we have a line" loop */        /* Corner case: linewrap with only "" wrapping to next line */        /* Looks ugly on screen, so we do not store this empty line */        if (!last_terminated && !current_line[0]) {            last_terminated = 1;            max_lineno++;            continue;        }reached_eof:        last_terminated = terminated;        flines = xrealloc(flines, (max_fline+1) * sizeof(char *));        if (option_mask32 & FLAG_N) {            /* Width of 7 preserves tab spacing in the text */            flines[max_fline] = xasprintf(                                    (max_lineno <= 9999999) ? "%7u %s" : "%07u %s",                                    max_lineno % 10000000, current_line);            free(current_line);            if (terminated)                max_lineno++;        } else {            flines[max_fline] = xrealloc(current_line, strlen(current_line)+1);        }        if (max_fline >= MAXLINES) {            eof_error = 0; /* Pretend we saw EOF */            break;        }        if (max_fline > cur_fline + max_displayed_line) {#if !ENABLE_FEATURE_LESS_REGEXP            break;#else            if (wanted_match >= num_matches) { /* goto_match called us */                fill_match_lines(old_max_fline);                old_max_fline = max_fline;            }            if (wanted_match < num_matches)                break;#endif        }        if (eof_error <= 0) {            if (eof_error < 0) {                if (errno == EAGAIN) {                    /* not yet eof or error, reset flag (or else                     * we will hog CPU - select() will return
开发者ID:OPSF,项目名称:uClinux,代码行数:67,


示例5: phase2_getc

static intphase2_getc (){  static char *buffer;  static size_t bufmax;  size_t buflen;  int lineno;  int c;  bool last_was_star;  if (phase2_pushback_length)    return phase2_pushback[--phase2_pushback_length];  if (char_in_line == 0)    {      /* Eat whitespace, to recognize ^[/t ]*# pattern.  */      do	c = phase1_getc ();      while (c == '/t' || c == ' ');      if (c == '#')	{	  /* sh comment.  */	  buflen = 0;	  lineno = line_number;	  for (;;)	    {	      c = phase1_getc ();	      if (c == '/n' || c == EOF)		break;	      /* We skip all leading white space, but not EOLs.  */	      if (!(buflen == 0 && (c == ' ' || c == '/t')))		{		  if (buflen >= bufmax)		    {		      bufmax = 2 * bufmax + 10;		      buffer = xrealloc (buffer, bufmax);		    }		  buffer[buflen++] = c;		}	    }	  if (buflen >= bufmax)	    {	      bufmax = 2 * bufmax + 10;	      buffer = xrealloc (buffer, bufmax);	    }	  buffer[buflen] = '/0';	  xgettext_comment_add (buffer);	  last_comment_line = lineno;	  return '/n';	}    }  else    c = phase1_getc ();  if (c == '/')    {      c = phase1_getc ();      switch (c)	{	default:	  phase1_ungetc (c);	  return '/';	case '*':	  /* C comment.  */	  buflen = 0;	  lineno = line_number;	  last_was_star = false;	  for (;;)	    {	      c = phase1_getc ();	      if (c == EOF)		break;	      /* We skip all leading white space, but not EOLs.  */	      if (buflen == 0 && (c == ' ' || c == '/t'))		continue;	      if (buflen >= bufmax)		{		  bufmax = 2 * bufmax + 10;		  buffer = xrealloc (buffer, bufmax);	        }	      buffer[buflen++] = c;	      switch (c)		{		case '/n':		  --buflen;		  while (buflen >= 1			 && (buffer[buflen - 1] == ' '			     || buffer[buflen - 1] == '/t'))		    --buflen;		  buffer[buflen] = '/0';		  xgettext_comment_add (buffer);		  buflen = 0;		  lineno = line_number;		  last_was_star = false;		  continue;		case '*'://.........这里部分代码省略.........
开发者ID:alan707,项目名称:senuti,代码行数:101,


示例6: cmd_format_patch

//.........这里部分代码省略.........			if (!(o->flags & UNINTERESTING))				head = (struct commit *)o;		}		/* We can't generate a cover letter without any patches */		if (!head)			return 0;	}	if (ignore_if_in_upstream)		get_patch_ids(&rev, &ids, prefix);	if (!use_stdout)		realstdout = xfdopen(xdup(1), "w");	if (prepare_revision_walk(&rev))		die("revision walk setup failed");	rev.boundary = 1;	while ((commit = get_revision(&rev)) != NULL) {		if (commit->object.flags & BOUNDARY) {			boundary_count++;			origin = (boundary_count == 1) ? commit : NULL;			continue;		}		/* ignore merges */		if (commit->parents && commit->parents->next)			continue;		if (ignore_if_in_upstream &&				has_commit_patch_id(commit, &ids))			continue;		nr++;		list = xrealloc(list, nr * sizeof(list[0]));		list[nr - 1] = commit;	}	total = nr;	if (!keep_subject && auto_number && total > 1)		numbered = 1;	if (numbered)		rev.total = total + start_number - 1;	if (in_reply_to || thread || cover_letter)		rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));	if (in_reply_to) {		const char *msgid = clean_message_id(in_reply_to);		string_list_append(msgid, rev.ref_message_ids);	}	rev.numbered_files = numbered_files;	rev.patch_suffix = fmt_patch_suffix;	if (cover_letter) {		if (thread)			gen_message_id(&rev, "cover");		make_cover_letter(&rev, use_stdout, numbered, numbered_files,				  origin, nr, list, head);		total++;		start_number--;	}	rev.add_signoff = add_signoff;	while (0 <= --nr) {		int shown;		commit = list[nr];		rev.nr = total - nr + (start_number - 1);		/* Make the second and subsequent mails replies to the first */		if (thread) {			/* Have we already had a message ID? */			if (rev.message_id) {
开发者ID:DJHartley,项目名称:git,代码行数:67,


示例7: mi_parse_argv

static voidmi_parse_argv (char *args, struct mi_parse *parse){  char *chp = args;  int argc = 0;  char **argv = xmalloc ((argc + 1) * sizeof (char *));  argv[argc] = NULL;  while (1)    {      char *arg;      /* skip leading white space */      while (isspace (*chp))	chp++;      /* Three possibilities: EOF, quoted string, or other text. */      switch (*chp)	{	case '/0':	  parse->argv = argv;	  parse->argc = argc;	  return;	case '"':	  {	    /* A quoted string. */	    int len;	    char *start = chp + 1;	    /* Determine the buffer size. */	    chp = start;	    len = 0;	    while (*chp != '/0' && *chp != '"')	      {		if (*chp == '//')		  {		    chp++;		    if (parse_escape (&chp) <= 0)		      {			/* Do not allow split lines or "/000" */			freeargv (argv);			return;		      }		  }		else		  chp++;		len++;	      }	    /* Insist on a closing quote. */	    if (*chp != '"')	      {		freeargv (argv);		return;	      }	    /* Insist on trailing white space. */	    if (chp[1] != '/0' && !isspace (chp[1]))	      {		freeargv (argv);		return;	      }	    /* create the buffer. */	    arg = xmalloc ((len + 1) * sizeof (char));	    /* And copy the characters in. */	    chp = start;	    len = 0;	    while (*chp != '/0' && *chp != '"')	      {		if (*chp == '//')		  {		    chp++;		    arg[len] = parse_escape (&chp);		  }		else		  arg[len] = *chp++;		len++;	      }	    arg[len] = '/0';	    chp++;		/* that closing quote. */	    break;	  }	default:	  {	    /* An unquoted string.  Accumulate all non blank	       characters into a buffer. */	    int len;	    char *start = chp;	    while (*chp != '/0' && !isspace (*chp))	      {		chp++;	      }	    len = chp - start;	    arg = xmalloc ((len + 1) * sizeof (char));	    strncpy (arg, start, len);	    arg[len] = '/0';	    break;	  }	}      /* Append arg to argv. */      argv = xrealloc (argv, (argc + 2) * sizeof (char *));      argv[argc++] = arg;      argv[argc] = NULL;    }}
开发者ID:sergiodj,项目名称:gdb-sergio,代码行数:99,


示例8: tgetent

//.........这里部分代码省略.........      if (!indirect)	{	  if (!bp)	    bp = termcap_name;	  else	    strcpy (bp, termcap_name);	  goto ret;	}      else	{			/* It has tc=.  Need to read /etc/termcap.  */	  tcenv = termcap_name; 	  termcap_name = NULL;	}    }  if (!termcap_name || !filep)    termcap_name = TERMCAP_FILE;  /* Here we know we must search a file and termcap_name has its name.  */#ifdef MSDOS  fd = open (termcap_name, O_RDONLY|O_TEXT, 0);#else  fd = open (termcap_name, O_RDONLY, 0);#endif  if (fd < 0)    return -1;  buf.size = BUFSIZE;  /* Add 1 to size to ensure room for terminating null.  */  buf.beg = (char *) xmalloc (buf.size + 1);  term = indirect ? indirect : (char *)name;  if (!bp)    {      malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;      bp = (char *) xmalloc (malloc_size);    }  tc_search_point = bp1 = bp;  if (indirect)    /* Copy the data from the environment variable.  */    {      strcpy (bp, tcenv);      bp1 += strlen (tcenv);    }  while (term)    {      /* Scan the file, reading it via buf, till find start of main entry.  */      if (scan_file (term, fd, &buf) == 0)	{	  close (fd);	  xfree (buf.beg);	  if (malloc_size)	    xfree (bp);	  return 0;	}      /* Free old `term' if appropriate.  */      if (term != name)	xfree (term);      /* If BP is malloc'd by us, make sure it is big enough.  */      if (malloc_size)	{	  ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp;	  malloc_size = offset1 + buf.size;	  bp = termcap_name = (char *) xrealloc (bp, malloc_size);	  bp1 = termcap_name + offset1;	  tc_search_point = termcap_name + offset2;	}      /* Copy the line of the entry from buf into bp.  */      termcap_name = buf.ptr;      while ((*bp1++ = c = *termcap_name++) && c != '/n')	/* Drop out any / newline sequence.  */	if (c == '//' && *termcap_name == '/n')	  {	    bp1--;	    termcap_name++;	  }      *bp1 = '/0';      /* Does this entry refer to another terminal type's entry?	 If something is found, copy it into heap and null-terminate it.  */      tc_search_point = find_capability (tc_search_point, "tc");      term = tgetst1 (tc_search_point, (char **) 0);    }  close (fd);  xfree (buf.beg);  if (malloc_size)    bp = (char *) xrealloc (bp, bp1 - bp + 1); ret:  term_entry = bp;  return 1;}
开发者ID:EwanDawson,项目名称:emacs,代码行数:101,


示例9: read_token

/* * Read and return a token.  Tokens are string or character literals * or else delimited by whitespace or by [(),{}]. * The latter are all returned as single characters. */static char *read_token(void){    int c, q;    char *buf;    unsigned int alc, off;    const char* delims = "(),{}";    while (1) {        c = getchar_skipping_comments();        if (c == EOF)            return NULL;        if (!isspace(c))            break;    }    alc = 16;    buf = xmalloc(alc + 1);    off = 0;    if(c == '"' || c == '/'') {        q = c;        buf[off] = c;        ++off;        while (1) {            if (off+2 >= alc) { // room for c and maybe next char                alc *= 2;                buf = xrealloc(buf, alc + 1);            }            c = getchar_no_eof();            buf[off] = c;            ++off;            if(c == q)                break;            if(c == '//') {                buf[off] = getchar_no_eof();                ++off;            }        }    } else if (strchr(delims, c) != NULL) {        buf[off] = c;        ++off;    } else {        while (1) {            if (off >= alc) {                alc *= 2;                buf = xrealloc(buf, alc + 1);            }            buf[off] = c;            ++off;            c = getchar_skipping_comments();            if (c == EOF)                break;            if (isspace(c) || strchr(delims, c) != NULL) {                if (c == '/n')                    lineno--;                ungetc(c, stdin);                break;            }        }    }    buf[off] = '/0';    return buf;}
开发者ID:rgmabs19357,项目名称:gcc,代码行数:67,


示例10: initialize_current_architecture

voidinitialize_current_architecture (void){  const char **arches = gdbarch_printable_names ();  struct gdbarch_info info;  /* determine a default architecture and byte order.  */  gdbarch_info_init (&info);    /* Find a default architecture.  */  if (default_bfd_arch == NULL)    {      /* Choose the architecture by taking the first one	 alphabetically.  */      const char *chosen = arches[0];      const char **arch;      for (arch = arches; *arch != NULL; arch++)	{	  if (strcmp (*arch, chosen) < 0)	    chosen = *arch;	}      if (chosen == NULL)	internal_error (__FILE__, __LINE__,			_("initialize_current_architecture: No arch"));      default_bfd_arch = bfd_scan_arch (chosen);      if (default_bfd_arch == NULL)	internal_error (__FILE__, __LINE__,			_("initialize_current_architecture: Arch not found"));    }  info.bfd_arch_info = default_bfd_arch;  /* Take several guesses at a byte order.  */  if (default_byte_order == BFD_ENDIAN_UNKNOWN      && default_bfd_vec != NULL)    {      /* Extract BFD's default vector's byte order.  */      switch (default_bfd_vec->byteorder)	{	case BFD_ENDIAN_BIG:	  default_byte_order = BFD_ENDIAN_BIG;	  break;	case BFD_ENDIAN_LITTLE:	  default_byte_order = BFD_ENDIAN_LITTLE;	  break;	default:	  break;	}    }  if (default_byte_order == BFD_ENDIAN_UNKNOWN)    {      /* look for ``*el-*'' in the target name.  */      const char *chp;      chp = strchr (target_name, '-');      if (chp != NULL	  && chp - 2 >= target_name	  && strncmp (chp - 2, "el", 2) == 0)	default_byte_order = BFD_ENDIAN_LITTLE;    }  if (default_byte_order == BFD_ENDIAN_UNKNOWN)    {      /* Wire it to big-endian!!! */      default_byte_order = BFD_ENDIAN_BIG;    }  info.byte_order = default_byte_order;  info.byte_order_for_code = info.byte_order;  if (! gdbarch_update_p (info))    internal_error (__FILE__, __LINE__,		    _("initialize_current_architecture: Selection of "		      "initial architecture failed"));  /* Create the ``set architecture'' command appending ``auto'' to the     list of architectures.  */  {    /* Append ``auto''.  */    int nr;    for (nr = 0; arches[nr] != NULL; nr++);    arches = xrealloc (arches, sizeof (char*) * (nr + 2));    arches[nr + 0] = "auto";    arches[nr + 1] = NULL;    add_setshow_enum_cmd ("architecture", class_support,			  arches, &set_architecture_string, 			  _("Set architecture of target."),			  _("Show architecture of target."), NULL,			  set_architecture, show_architecture,			  &setlist, &showlist);    add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);  }}
开发者ID:Levi-Armstrong,项目名称:gdb-7.7.1,代码行数:91,


示例11: container_p_create

extern int container_p_create(uint32_t job_id){#ifdef HAVE_NATIVE_CRAY	rid_t resv_id = job_id;	int rc;#endif	int i, empty = -1, found = -1;	DEF_TIMERS;	START_TIMER;	if (debug_flags & DEBUG_FLAG_JOB_CONT)		info("%s: creating(%u)", plugin_type, job_id);	slurm_mutex_lock(&context_lock);	for (i = 0; i < job_id_count; i++) {		if (job_id_array[i] == 0) {			empty = i;		} else if (job_id_array[i] == job_id) {			found = i;			break;		}	}	if (found == -1) {		if (empty == -1) {			empty = job_id_count;			job_id_count += 4;			job_id_array = xrealloc(job_id_array,						sizeof(uint32_t)*job_id_count);		}		job_id_array[empty] = job_id;		_save_state(state_dir);	}	slurm_mutex_unlock(&context_lock);	if (debug_flags & DEBUG_FLAG_TIME_CRAY) {		END_TIMER;		INFO_LINE("call took: %s", TIME_STR);	} else {		END_TIMER3("container_p_create: saving state took", 3000000);	}#ifdef HAVE_NATIVE_CRAY	START_TIMER;	rc = job_create_reservation(resv_id, CREATE_FLAGS);	if (debug_flags & DEBUG_FLAG_TIME_CRAY) {		END_TIMER;		INFO_LINE("call took: %s", TIME_STR);	} else		END_TIMER3("container_p_create: job_create_reservation took",			   3000000);	if ((rc == 0) || (errno == EEXIST)) {		if ((found == -1) && (rc != 0) && (errno == EEXIST)) {			error("%s: create(%u): Reservation already exists",			      plugin_type, job_id);		}		if (debug_flags & DEBUG_FLAG_JOB_CONT)			_stat_reservation("create", resv_id);		return SLURM_SUCCESS;	}	error("%s: create(%u): %m", plugin_type, job_id);	return SLURM_ERROR;#else	return SLURM_SUCCESS;#endif}
开发者ID:chrisdukey,项目名称:slurm,代码行数:63,


示例12: poptParseArgvString

int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr){    const char * se;    char quote = '/0';    size_t argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;    const char ** argv = (const char**) xmalloc(sizeof(*argv) * argvAlloced);    unsigned int argc = 0;    size_t ns = strlen(s);    char * t = NULL;    char * te;    int rc = POPT_ERROR_MALLOC;assert(argv);	/* XXX can't happen */    if (argv == NULL) return rc;    te = t = (char*) xmalloc(ns + 1);assert(te);	/* XXX can't happen */    if (te == NULL) {	argv = _free(argv);	return rc;    }    *te = '/0';    argv[argc] = te;    for (se = s; *se != '/0'; se++) {	if (quote == *se) {	    quote = '/0';	} else if (quote != '/0') {	    if (*se == '//') {		se++;		if (*se == '/0') {		    rc = POPT_ERROR_BADQUOTE;		    goto exit;		}		if (*se != quote) *te++ = '//';	    }	    *te++ = *se;	} else if (_isspaceptr(se)) {	    if (*argv[argc] != '/0') {		*te++ = '/0', argc++;		if (argc == argvAlloced) {		    argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;		    argv = (const char**) xrealloc(argv, sizeof(*argv) * argvAlloced);assert(argv);	/* XXX can't happen */		    if (argv == NULL) goto exit;		}		*te = '/0';		argv[argc] = te;	    }	} else	switch (*se) {	  case '"':	  case '/'':	    quote = *se;	    /*@[email
C++ xreallocarray函数代码示例
C++ xread函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。