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

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

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

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

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


示例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,


示例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 countxbt_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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: 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 compute_duration 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 compute_duration,                         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->message_size = message_size;  simdata->computation_amount = compute_duration;  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->comp_amount = NULL;  simdata->comm_amount = NULL;#ifdef HAVE_TRACING  TRACE_msg_task_create(task);#endif  return task;}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:54,


示例17: main

int main(int argc, char **argv){  xbt_dynar_t dax;  unsigned int cursor;  SD_task_t task;  /* SD initialization */  SD_init(&argc, argv);  /* Check our arguments */  xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]/n"       "/tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", argv[0], argv[0]);  char *last = strrchr(argv[2], '.');  char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? strlen(argv[2]):last - argv[2]), argv[2]);  if (argc == 4)    tracefilename = xbt_strdup(argv[3]);  /* creation of the environment */  SD_create_environment(argv[1]);  /* load the DAX file */  dax = SD_daxload(argv[2]);  if (!dax){    XBT_ERROR("A problem occurred during DAX parsing (cycle or syntax). Do not continue this test");    free(tracefilename);    SD_exit();    exit(255);  }  /* Display all the tasks */  XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");  xbt_dynar_foreach(dax, cursor, task) {    SD_task_dump(task);  }
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:35,


示例18: Java_org_simgrid_msg_Msg_run

JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls){  /* Run everything */  XBT_DEBUG("Ready to run MSG_MAIN");  msg_error_t rv = MSG_main();  XBT_DEBUG("Done running MSG_MAIN");  jxbt_check_res("MSG_main()", rv, MSG_OK,                 xbt_strdup("unexpected error : MSG_main() failed .. please report this bug "));  XBT_INFO("MSG_main finished; Cleaning up the simulation...");  /* Cleanup java hosts */  xbt_dynar_t hosts = MSG_hosts_as_dynar();  for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {    msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);    jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);    if (jhost)      jhost_unref(env, jhost);  }  xbt_dynar_free(&hosts);  /* Cleanup java storages */  xbt_dynar_t storages = MSG_storages_as_dynar();  if(!xbt_dynar_is_empty(storages)){    for (unsigned long index = 0; index < xbt_dynar_length(storages) - 1; index++) {      jobject jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);      if (jstorage)        jstorage_unref(env, jstorage);    }  }  xbt_dynar_free(&storages);}
开发者ID:oar-team,项目名称:simgrid-batsim,代码行数:32,


示例19: buff_size_to_string

static char* buff_size_to_string(size_t buff_size) {  if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))    return bprintf("%zu", buff_size);  return xbt_strdup("(verbose only)");}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:7,


示例20: __MSG_host_create

/********************************* Host **************************************/m_host_t __MSG_host_create(smx_host_t workstation, void *data){  const char *name;  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);  m_host_t host = xbt_new0(s_m_host_t, 1);  int i;  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */  name = SIMIX_host_get_name(workstation);  /* Host structure */  host->name = xbt_strdup(name);  host->simdata = simdata;  host->data = data;  simdata->smx_host = workstation;  if (msg_global->max_channel > 0)    simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);  for (i = 0; i < msg_global->max_channel; i++) {    sprintf(alias, "%s:%d", name, i);    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */    simdata->mailboxes[i] = MSG_mailbox_new(alias);    memset(alias, 0, MAX_ALIAS_NAME + 1);  }  SIMIX_req_host_set_data(workstation, host);  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);  return host;}
开发者ID:rosacris,项目名称:simgrid,代码行数:34,


示例21: pointer_to_string

static char* pointer_to_string(void* pointer) {  if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))    return bprintf("%p", pointer);  return xbt_strdup("(verbose only)");}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:7,


示例22: main

int main(int argc, char **argv){  xbt_dynar_t dot;  unsigned int cursor;  SD_task_t task;  /* initialization of SD */  SD_init(&argc, argv);  /* Check our arguments */  xbt_assert(argc > 2, "Usage: %s platform_file dot_file [trace_file]"             "example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0], argv[0]);  /* creation of the environment */  SD_create_environment(argv[1]);  /* load the DOT file */  dot = SD_dotload(argv[2]);  if(dot == NULL){    XBT_CRITICAL("No dot loaded. Do you have a cycle in your graph?");    SD_exit();    exit(2);  }  char *tracefilename;  char *last = strrchr(argv[2], '.');  tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);  if (argc == 4)     tracefilename = xbt_strdup(argv[3]);  /* Display all the tasks */  XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");  xbt_dynar_foreach(dot, cursor, task) {    SD_task_dump(task);  }
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:35,


示例23: xbt_workload_elm_parse

xbt_workload_elm_t xbt_workload_elm_parse(char *line){    xbt_workload_elm_t res = xbt_new(s_xbt_workload_elm_t, 1);    res->date = -1;    res->comment = NULL;          /* it's not enough to memset for valgrind, apparently */    res->who = NULL;    res->str_arg = NULL;    xbt_dynar_t w = xbt_str_split(line, " ");    if (xbt_dynar_length(w) == 0) {        free(res);        xbt_dynar_free(&w);        return NULL;    }    char **words = xbt_dynar_get_ptr(w, 0);    int i = 0;    if (words[i][0] == '[') {        sscanf(words[i] + 1, "%lg", &(res->date));        i++;    }    res->who = xbt_strdup(words[i++]);    if (!strcmp(words[i], "recv")) {        res->action = XBT_WORKLOAD_RECV;        res->str_arg = xbt_strdup(words[++i]);        sscanf(words[++i], "%lg", &(res->d_arg));    } else if (!strcmp(words[i], "send")) {        res->action = XBT_WORKLOAD_SEND;        res->str_arg = xbt_strdup(words[++i]);        sscanf(words[++i], "%lg", &(res->d_arg));    } else if (!strcmp(words[i], "compute")) {        res->action = XBT_WORKLOAD_COMPUTE;        sscanf(words[++i], "%lg", &(res->d_arg));    } else {        xbt_die("Unparsable command: %s (in %s)", words[i], line);    }    i++;    if (words[i] && words[i][0] == '#') {        res->comment = xbt_strdup(strchr(line, '#') + 1);    }    xbt_dynar_free(&w);    return res;}
开发者ID:rosacris,项目名称:simgrid,代码行数:47,


示例24: host

int host(int argc, char *argv[]){  msg_file_t file = NULL;  char* mount = xbt_strdup("/home");  size_t write;  // First open  XBT_INFO("/tOpen file '%s'",FILENAME1);  file = MSG_file_open(mount,FILENAME1);  // Unlink the file  XBT_INFO("/tUnlink file '%s'",file->fullname);  MSG_file_unlink(file);  // Re Open the file wich is in fact created  XBT_INFO("/tOpen file '%s'",FILENAME1);  file = MSG_file_open(mount,FILENAME1);  // Write into the new file  write = MSG_file_write(100000,file);  // Write for 100Ko  XBT_INFO("/tHave written %zu on %s",write,file->fullname);  // Close the file  XBT_INFO("/tClose file '%s'",file->fullname);  MSG_file_close(file);  xbt_dict_t dict_ls;  char* key;  surf_stat_t data = NULL;  xbt_dict_cursor_t cursor = NULL;  dict_ls = MSG_file_ls(mount,"./");  XBT_INFO(" ");XBT_INFO("ls ./");  xbt_dict_foreach(dict_ls,cursor,key,data){    if(data) XBT_INFO("FILE : %s",key);    else     XBT_INFO("DIR  : %s",key);  }  xbt_dict_free(&dict_ls);  dict_ls = MSG_file_ls(mount,"./doc/simgrid/examples/platforms/");  XBT_INFO(" ");XBT_INFO("ls ./doc/simgrid/examples/platforms/");  xbt_dict_foreach(dict_ls,cursor,key,data){    if(data) XBT_INFO("FILE : %s",key);    else     XBT_INFO("DIR  : %s",key);  }  xbt_dict_free(&dict_ls);  dict_ls = MSG_file_ls(mount,"./doc/simgrid/examples/msg/");  XBT_INFO(" ");XBT_INFO("ls ./doc/simgrid/examples/msg/");  xbt_dict_foreach(dict_ls,cursor,key,data){    if(data) XBT_INFO("FILE : %s",key);    else     XBT_INFO("DIR  : %s",key);  }  xbt_dict_free(&dict_ls);  free(mount);  return 0;}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:59,


示例25: xbt_strdup

static char *str_tolower (const char *str){  char *ret = xbt_strdup (str);  int i, n = strlen (ret);  for (i = 0; i < n; i++)    ret[i] = tolower (str[i]);  return ret;}
开发者ID:dhascome,项目名称:simgrid,代码行数:8,


示例26: Java_org_simgrid_msg_Msg_init

JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs){  char **argv = nullptr;  int index;  int argc = 0;  jstring jval;  const char *tmp;  XBT_LOG_CONNECT(jmsg);  XBT_LOG_CONNECT(jtrace);  env->GetJavaVM(&__java_vm);  simgrid::simix::factory_initializer = simgrid::java::java_factory;  jthrowable exc = env->ExceptionOccurred();  if (exc) {    env->ExceptionClear();  }  setlocale(LC_NUMERIC,"C");  if (jargs)    argc = (int) env->GetArrayLength(jargs);  argc++;  argv = xbt_new(char *, argc + 1);  argv[0] = xbt_strdup("java");  for (index = 0; index < argc - 1; index++) {    jval = (jstring) env->GetObjectArrayElement(jargs, index);    tmp = env->GetStringUTFChars(jval, 0);    argv[index + 1] = xbt_strdup(tmp);    env->ReleaseStringUTFChars(jval, tmp);  }  argv[argc] = nullptr;  MSG_init(&argc, argv);  JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(__JAVA_host_priv_free);  JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free);  for (index = 0; index < argc; index++)    free(argv[index]);  free(argv);}
开发者ID:oar-team,项目名称:simgrid-batsim,代码行数:46,


示例27: Resource

Storage::Storage(Model *model, const char *name, xbt_dict_t props,                 lmm_system_t maxminSystem, double bread, double bwrite,                 double bconnection, const char* type_id, char *content_name,                 char *content_type, sg_size_t size, char *attach) :  Resource(model, name, props, lmm_constraint_new(maxminSystem, this, bconnection)) , p_contentType(content_type) , m_size(size), m_usedSize(0) , p_typeId(xbt_strdup(type_id)) , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) {  surf_callback_emit(storageCreatedCallbacks, this);  p_content = parseContent(content_name);  p_attach = xbt_strdup(attach);  setState(SURF_RESOURCE_ON);  XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);  p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);  p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);}
开发者ID:apargupta,项目名称:simgrid,代码行数:17,


示例28: xbt_str_split_quoted

xbt_dynar_t xbt_str_split_quoted(const char *s){  xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);  xbt_dynar_t parsed;  char *str_to_free;            /* we have to copy the string before, to handle backslashes */  unsigned int cursor;  char *p;  if (s[0] == '/0')    return res;  str_to_free = xbt_strdup(s);  parsed = xbt_str_split_quoted_in_place(str_to_free);  xbt_dynar_foreach(parsed,cursor,p) {    char *q=xbt_strdup(p);    xbt_dynar_push(res,&q);  }
开发者ID:FlorianPO,项目名称:simgrid,代码行数:17,



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


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