当前位置: 首页>>代码示例>>C++>>正文


C++ xbt_strdup函数代码示例

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


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

示例1: XBT_DEBUG

StorageAction *StorageN11::open(const char* mount, const char* path)
{
  XBT_DEBUG("\tOpen file '%s'",path);

  sg_size_t size, *psize;
  psize = (sg_size_t*) xbt_dict_get_or_null(content_, path);
  // if file does not exist create an empty file
  if(psize)
    size = *psize;
  else {
    psize = xbt_new(sg_size_t,1);
    size = 0;
    *psize = size;
    xbt_dict_set(content_, path, psize, nullptr);
    XBT_DEBUG("File '%s' was not found, file created.",path);
  }
  surf_file_t file = xbt_new0(s_surf_file_t,1);
  file->name = xbt_strdup(path);
  file->size = size;
  file->mount = xbt_strdup(mount);
  file->current_position = 0;

  StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, OPEN);
  action->p_file = file;

  return action;
}
开发者ID:fabienchaix,项目名称:simgrid,代码行数:27,代码来源:storage_n11.cpp

示例2: parse_ns3_add_link

static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
{
  XBT_DEBUG("NS3_ADD_LINK '%s'",link->id);

  if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free);

  tmgr_trace_t bw_trace;
  tmgr_trace_t state_trace;
  tmgr_trace_t lat_trace;

  bw_trace = link->bandwidth_trace;
  lat_trace = link->latency_trace;
  state_trace = link->state_trace;

  if (bw_trace)
    XBT_INFO("The NS3 network model doesn't support bandwidth state traces");
  if (lat_trace)
    XBT_INFO("The NS3 network model doesn't support latency state traces");
  if (state_trace)
    XBT_INFO("The NS3 network model doesn't support link state traces");

  ns3_link_t link_ns3 = xbt_new0(s_ns3_link_t,1);;
  link_ns3->id = xbt_strdup((char*)(link->id));
  link_ns3->bdw = bprintf("%f",link->bandwidth);
  link_ns3->lat = bprintf("%f",link->latency);

  surf_ns3_link_t l = xbt_new0(s_surf_ns3_link_t,1);
  l->generic_resource.name = xbt_strdup(link->id);
  l->generic_resource.properties = current_property_set;
  l->data = link_ns3;
  l->created = 1;

  xbt_lib_set(link_lib,link->id,NS3_LINK_LEVEL,link_ns3);
  xbt_lib_set(link_lib,link->id,SURF_LINK_LEVEL,l);
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:35,代码来源:network_ns3.c

示例3: xbt_log_appender2_file_new

//syntax is  <maxsize>:<filename>
//If roll is 0, use split files, otherwise, use roll file
//For split, replace %  in the file by the current count
xbt_log_appender_t xbt_log_appender2_file_new(char *arg,int roll) {

  xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
  if (_XBT_LOGV(smpi).initialized) // HACK to detect if we run in SMPI mode. Relies on MAIN__ source disposition
    res->do_append = smpi_append2_file;
  else
    res->do_append = append2_file;
  res->free_ = free_append2_;
  xbt_log_append2_file_t data = xbt_new0(struct xbt_log_append2_file_s, 1);
  xbt_assert(arg);
  char* buf=xbt_strdup(arg);
  char* sep=strchr(buf,':');
  xbt_assert(sep>0);
  data->filename=xbt_strdup(sep+1);
  *sep='\0';
  char *endptr;
  data->limit=strtol(buf,&endptr,10);
  xbt_assert(endptr[0]=='\0', "Invalid buffer size: %s", buf);
  xbt_free(buf);
  if(roll)
    data->count=-1;
  else
    data->count=0;
  open_append2_file(data);  
  res->data = data;
  return res;
}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:30,代码来源:xbt_log_appender_file.c

示例4: gras_process_init

void gras_process_init()
{
  char **env_iter;
  _gras_procdata = xbt_new0(gras_procdata_t, 1);
  gras_procdata_init();

  /* initialize the host & process properties */
  _host_properties = xbt_dict_new();
  _process_properties = xbt_dict_new();
  env_iter = environ;
  while (*env_iter) {
    char *equal, *buf = xbt_strdup(*env_iter);
    equal = strchr(buf, '=');
    if (!equal) {
      XBT_WARN
          ("The environment contains an entry without '=' char: %s (ignore it)",
           *env_iter);
      continue;
    }
    *equal = '\0';
    xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1),
                 xbt_free_f);
    free(buf);
    env_iter++;
  }
}
开发者ID:rosacris,项目名称:simgrid,代码行数:26,代码来源:rl_process.c

示例5: linkContainers

static void linkContainers (container_t src, container_t dst, xbt_dict_t filter)
{
  //ignore loopback
  if (strcmp (src->name, "__loopback__") == 0 || strcmp (dst->name, "__loopback__") == 0){
    XBT_DEBUG ("  linkContainers: ignoring loopback link");
    return;
  }

  //find common father
  container_t father = lowestCommonAncestor (src, dst);
  if (!father){
    xbt_die ("common father unknown, this is a tracing problem");
  }

  if (filter != NULL){
    //check if we already register this pair (we only need one direction)
    char aux1[INSTR_DEFAULT_STR_SIZE], aux2[INSTR_DEFAULT_STR_SIZE];
    snprintf (aux1, INSTR_DEFAULT_STR_SIZE, "%s%s", src->name, dst->name);
    snprintf (aux2, INSTR_DEFAULT_STR_SIZE, "%s%s", dst->name, src->name);
    if (xbt_dict_get_or_null (filter, aux1)){
      XBT_DEBUG ("  linkContainers: already registered %s <-> %s (1)", src->name, dst->name);
      return;
    }
    if (xbt_dict_get_or_null (filter, aux2)){
      XBT_DEBUG ("  linkContainers: already registered %s <-> %s (2)", dst->name, src->name);
      return;
    }

    //ok, not found, register it
    xbt_dict_set (filter, aux1, xbt_strdup ("1"), NULL);
    xbt_dict_set (filter, aux2, xbt_strdup ("1"), NULL);
  }

  //declare type
  char link_typename[INSTR_DEFAULT_STR_SIZE];
  snprintf (link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s",
            father->type->name,
            src->type->name, src->type->id,
            dst->type->name, dst->type->id);
  type_t link_type = PJ_type_get_or_null (link_typename, father->type);
  if (link_type == NULL){
    link_type = PJ_type_link_new (link_typename, father->type, src->type, dst->type);
  }

  //register EDGE types for triva configuration
  xbt_dict_set (trivaEdgeTypes, link_type->name, xbt_strdup("1"), NULL);

  //create the link
  static long long counter = 0;

  char key[INSTR_DEFAULT_STR_SIZE];
  snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
  new_pajeStartLink(SIMIX_get_clock(), father, link_type, src, "topology", key);
  new_pajeEndLink(SIMIX_get_clock(), father, link_type, dst, "topology", key);

  XBT_DEBUG ("  linkContainers %s <-> %s", src->name, dst->name);
}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:57,代码来源:instr_routing.cpp

示例6: vm_migrate_async

static void vm_migrate_async(msg_vm_t vm, msg_host_t dst_pm)
{
  const char *vm_name = MSG_vm_get_name(vm);
  const char *dst_pm_name = MSG_host_get_name(dst_pm);
  msg_host_t host = MSG_host_self();

  const char *pr_name = "mig_wrk";
  char **argv = xbt_new(char *, 4);
  argv[0] = xbt_strdup(pr_name);
  argv[1] = xbt_strdup(vm_name);
  argv[2] = xbt_strdup(dst_pm_name);
  argv[3] = NULL;

  MSG_process_create_with_arguments(pr_name, migration_worker_main, NULL, host, 3, argv);
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:15,代码来源:cloud-migration.c

示例7: MSG_task_execute

/** \ingroup m_task_management
 * \brief Creates a new #msg_task_t.
 *
 * A constructor for #msg_task_t taking four arguments and returning the
   corresponding object.
 * \param name a name for the object. It is for user-level information
   and can be NULL.
 * \param flop_amount a value of the processing amount (in flop)
   needed to process this new task. If 0, then it cannot be executed with
   MSG_task_execute(). This value has to be >=0.
 * \param message_size a value of the amount of data (in bytes) needed to
   transfer this new task. If 0, then it cannot be transfered with
   MSG_task_send() and MSG_task_recv(). This value has to be >=0.
 * \param data a pointer to any data may want to attach to the new
   object.  It is for user-level information and can be NULL. It can
   be retrieved with the function \ref MSG_task_get_data.
 * \see msg_task_t
 * \return The new corresponding object.
 */
msg_task_t MSG_task_create(const char *name, double flop_amount,
                         double message_size, void *data)
{
  msg_task_t task = xbt_new(s_msg_task_t, 1);
  simdata_task_t simdata = xbt_new(s_simdata_task_t, 1);
  task->simdata = simdata;

  /* Task structure */
  task->name = xbt_strdup(name);
  task->data = data;

  /* Simulator Data */
  simdata->compute = NULL;
  simdata->comm = NULL;
  simdata->bytes_amount = message_size;
  simdata->flops_amount = flop_amount;
  simdata->sender = NULL;
  simdata->receiver = NULL;
  simdata->source = NULL;
  simdata->priority = 1.0;
  simdata->bound = 0;
  simdata->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
  simdata->rate = -1.0;
  simdata->isused = 0;

  simdata->host_nb = 0;
  simdata->host_list = NULL;
  simdata->flops_parallel_amount = NULL;
  simdata->bytes_parallel_amount = NULL;
  TRACE_msg_task_create(task);

  return task;
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:52,代码来源:msg_task.c

示例8: master

/** Emitter function  */
int master(int argc, char *argv[])
{
  long number_of_tasks = atol(argv[1]);
  double task_comp_size = atof(argv[2]);
  double task_comm_size = atof(argv[3]);
  long slaves_count = atol(argv[4]);
  XBT_INFO("master %ld %f %f %ld", number_of_tasks, task_comp_size,
        task_comm_size, slaves_count);

  int i;
  for (i = 0; i < number_of_tasks; i++) {
    char task_name[100];
    snprintf (task_name, 100, "task-%d", i);
    m_task_t task = NULL;
    task = MSG_task_create(task_name, task_comp_size, task_comm_size, NULL);

    //setting the category of task to "compute"
    //the category of a task must be defined before it is sent or executed
    TRACE_msg_set_task_category(task, "compute");
    MSG_task_send(task, "master_mailbox");
  }

  for (i = 0; i < slaves_count; i++) {
    char task_name[100];
    snprintf (task_name, 100, "task-%d", i);
    m_task_t finalize = MSG_task_create(task_name, 0, 0, xbt_strdup("finalize"));
    TRACE_msg_set_task_category(finalize, "finalize");
    MSG_task_send(finalize, "master_mailbox");
  }

  return 0;
}
开发者ID:rosacris,项目名称:simgrid,代码行数:33,代码来源:tasks.c

示例9: replace_lat_ns3

static void replace_lat_ns3(char ** lat)
{
  char *temp = xbt_strdup(*lat);
  xbt_free(*lat);
  *lat = bprintf("%fs",atof(temp));
  xbt_free(temp);
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:7,代码来源:network_ns3.c

示例10: xbt_strbuff_new_from

/** @brief creates a new string buffer containing the provided string
 *
 * Beware, the ctn is copied, you want to free it afterward, anyhow
 */
XBT_INLINE xbt_strbuff_t xbt_strbuff_new_from(const char *ctn)
{
  xbt_strbuff_t res = malloc(sizeof(s_xbt_strbuff_t));
  res->data = xbt_strdup(ctn);
  res->used = res->size = strlen(ctn);
  return res;
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:11,代码来源:xbt_strbuff.c

示例11: master

static int master(int argc, char *argv[])
{
  msg_task_t task = NULL;

  // I am the master of emigrant process,
  // I tell it where it must emigrate to.
  xbt_dynar_t destinations = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Jupiter"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Bourassa"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette"));
  xbt_dynar_push_as (destinations, char*, NULL);

  char *destination;
  unsigned int i;
  xbt_dynar_foreach(destinations, i, destination){
    task = MSG_task_create("task", 0, 0, NULL);
    if (destination){
      MSG_task_set_data(task, xbt_strdup (destination));
    }
    MSG_task_set_category(task, "migration_order");
    MSG_task_send (task, "master_mailbox");
    task = NULL;
  }
开发者ID:Shurakai,项目名称:SimGrid,代码行数:28,代码来源:procmig.c

示例12: parse_S_host

/**
 * \brief Add a "host" to the network element list
 */
static void parse_S_host(sg_platf_host_cbarg_t host)
{
  if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
    current_routing->p_hierarchy = SURF_ROUTING_BASE;
  xbt_assert(!sg_host_by_name(host->id),
		     "Reading a host, processing unit \"%s\" already exists", host->id);

  RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(host->id),
		                                    -1,
		                                    SURF_NETWORK_ELEMENT_HOST,
		                                    current_routing);
  info->setId(current_routing->parsePU(info));
  sg_host_edge_set(sg_host_by_name_or_create(host->id), info);
  XBT_DEBUG("Having set name '%s' id '%d'", host->id, info->getId());

  if(mount_list){
    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
    mount_list = NULL;
  }

  if (host->coord && strcmp(host->coord, "")) {
    unsigned int cursor;
    char*str;

    if (!COORD_HOST_LEVEL)
      xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
    /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/
    xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " ");
    xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
    xbt_dynar_foreach(ctn_str,cursor, str) {
      double val = atof(str);
      xbt_dynar_push(ctn,&val);
    }
开发者ID:apargupta,项目名称:simgrid,代码行数:36,代码来源:surf_routing.cpp

示例13: client

static int client(int argc, char *argv[])
{
  int my_pid = MSG_process_get_PID(MSG_process_self());
  char *my_mailbox = xbt_strdup(argv[1]);

  while(1){
    XBT_INFO("Client (%s) asks the request", my_mailbox);
    MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");

    msg_task_t answer = NULL;
    MSG_task_receive(&answer, my_mailbox);

    const char* kind = MSG_task_get_name(answer);

    if (!strcmp(kind, "grant")) {
      XBT_INFO("Client (%s) got the answer (grant). Sleep a bit and release it", my_mailbox);
      if(!strcmp(my_mailbox, "1"))
        cs = 1;
    }else{
      XBT_INFO("Client (%s) got the answer (not grant). Try again", my_mailbox);
    }

    MSG_task_destroy(answer);
    kind = NULL;

    MSG_process_sleep(my_pid);
  }
  return 0;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:29,代码来源:bugged2_liveness.c

示例14: surf_action_set_category

void surf_action_set_category(surf_action_t action,
                                    const char *category)
{
  XBT_IN("(%p,%s)", action, category);
  action->category = xbt_strdup(category);
  XBT_OUT();
}
开发者ID:cemsbr,项目名称:simgrid,代码行数:7,代码来源:surf_action.c

示例15: open_append2_file

static void open_append2_file(xbt_log_append2_file_t data){
  if(data->count<0)
  {
    //Roll
    if(!data->file)
      data->file= fopen(data->filename, "w");
    else{
      fputs(APPEND2_END_TOKEN_CLEAR,data->file);
      fseek(data->file,0,SEEK_SET);
    }
  }
  else{
    //printf("Splitting\n");
    //Split
    if(data->file)
      fclose(data->file);
    char newname[512];
    char* pre=xbt_strdup(data->filename);
    char* sep=strchr(pre,'%');
    if(!sep)
      sep=pre+strlen(pre);
    char* post=sep+1;
    *sep='\0';
    snprintf(newname,511,"%s%i%s",pre,data->count,post);
    data->count++;
    data->file= fopen(newname, "w");
    xbt_assert(data->file);

  }
}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:30,代码来源:xbt_log_appender_file.c


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