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

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

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

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

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

示例1: test_container_smartlist_digests

/** Run unit tests for smartlist-of-digests functions. */static voidtest_container_smartlist_digests(void *unused){  smartlist_t *sl = smartlist_create();  /* digest_isin. */  smartlist_add(sl, xmemdup("AAAAAAAAAAAAAAAAAAAA", SHA256_LENGTH));  smartlist_add(sl, xmemdup("/00090AAB2AAAAaasdAAAAA", SHA256_LENGTH));  smartlist_add(sl, xmemdup("/00090AAB2AAAAaasdAAAAA", SHA256_LENGTH));  tt_int_op(smartlist_digest_isin(NULL, "AAAAAAAAAAAAAAAAAAAA"), ==, 0);  tt_assert(smartlist_digest_isin(sl, "AAAAAAAAAAAAAAAAAAAA"));  tt_assert(smartlist_digest_isin(sl, "/00090AAB2AAAAaasdAAAAA"));  tt_int_op(smartlist_digest_isin(sl, "/00090AAB2AAABaasdAAAAA"), ==, 0);  /* sort digests */  smartlist_sort_digests(sl);  tt_mem_op(smartlist_get(sl, 0), ==, "/00090AAB2AAAAaasdAAAAA", SHA256_LENGTH);  tt_mem_op(smartlist_get(sl, 1), ==, "/00090AAB2AAAAaasdAAAAA", SHA256_LENGTH);  tt_mem_op(smartlist_get(sl, 2), ==, "AAAAAAAAAAAAAAAAAAAA", SHA256_LENGTH);  tt_int_op(smartlist_len(sl), ==, 3);  /* uniq_digests */  smartlist_uniq_digests(sl);  tt_int_op(smartlist_len(sl), ==, 2);  tt_mem_op(smartlist_get(sl, 0), ==, "/00090AAB2AAAAaasdAAAAA", SHA256_LENGTH);  tt_mem_op(smartlist_get(sl, 1), ==, "AAAAAAAAAAAAAAAAAAAA", SHA256_LENGTH); end:  SMARTLIST_FOREACH(sl, char *, cp, free(cp));  smartlist_free(sl);}
开发者ID:FredericJacobs,项目名称:obfsproxy-c,代码行数:32,


示例2: path_split

intpath_split(const unsigned char *path, unsigned char ***p_split){  path_t p;  unsigned char *s, *q;  int cnt, i;  unsigned char **split;  snprintf(p, sizeof(p), "%s", path);  os_normalize_path(p);  // count the '/'  for (s = p, cnt = 1; *s; s++)    if (*s == '/') cnt++;  XCALLOC(split, cnt + 1);  s = p;  i = 0;  if (*s == '/') {    split[i++] = xmemdup(s++, 1);  }  while (*s) {    q = s;    while (*q && *q != '/') q++;    split[i++] = xmemdup(s, q - s);    if (*q == '/') q++;    s = q;  }  split[i] = 0;  *p_split = split;  return i;}
开发者ID:NUOG,项目名称:ejudge,代码行数:32,


示例3: SLPCompareString

/** Compares two non-normalized strings. * * Normalizes two strings by removing leading and trailing white space, * folding internal white space and unescaping the strings first, and then * calling SLPCompareNormalizedString (as per RFC 2608, section 6.4). * * @param[in] str1 - A pointer to string to be compared. * @param[in] str1len - The length of str1 in bytes. * @param[in] str2 - A pointer to string to be compared. * @param[in] str2len - The length of str2 in bytes. * * @return Zero if @p str1 is equal to @p str2, less than zero if @p str1 *    is greater than @p str2, greater than zero if @p str1 is less than *    @p str2. */int SLPCompareString(size_t str1len, const char * str1,      size_t str2len, const char * str2){   int result;   char * cpy1, * cpy2;   /* Remove leading white space. */   while (str1len && isspace(*str1))      str1++, str1len--;   while (str2len && isspace(*str2))      str2++, str2len--;   /* Remove trailing white space. */   while (str1len && isspace(str1[str1len - 1]))      str1len--;   while (str2len && isspace(str2[str2len - 1]))      str2len--;   /*A quick check for empty strings before we start xmemduping and xfreeing*/   if (str1len == 0 || str2len == 0)   {      if(str1len == str2len)         return 0;      if(str1len < str2len)         return -1;      return 1;   }   /* Make modifiable copies. If either fails, compare original strings. */   cpy1 = xmemdup(str1, str1len);   cpy2 = xmemdup(str2, str2len);   if (cpy1 != 0 && cpy2 != 0)   {      /* Unescape copies in place. */      str1len = SLPUnescapeInPlace(str1len, cpy1);      str2len = SLPUnescapeInPlace(str2len, cpy2);      /* Fold white space in place. */      str1len = SLPFoldWhiteSpace(str1len, cpy1);      str2len = SLPFoldWhiteSpace(str2len, cpy2);      /* Reset original pointers to modified copies. */      str1 = cpy1;      str2 = cpy2;   }   /* Comparison logic. */   if (str1len == str2len)      result = SLPCompareNormalizedString(str1, str2, str1len);   else if (str1len > str2len)      result = -1;   else      result = 1;   xfree(cpy1);   xfree(cpy2);   return result;}
开发者ID:eSDK,项目名称:eSDK_OBS_API,代码行数:74,


示例4: sizeof

/* * Duplicate the given seqset. */EXPORTED struct seqset *seqset_dup(const struct seqset *l){    struct seqset *newl;    newl = (struct seqset *)xmemdup(l, sizeof(*l));    newl->set = (struct seq_range *)xmemdup(newl->set,                    newl->alloc * sizeof(struct seq_range));    return newl;}
开发者ID:brong,项目名称:cyrus-imapd,代码行数:13,


示例5: send_bpdu

static voidsend_bpdu(struct ofpbuf *pkt, int port_no, void *b_){    struct bridge *b = b_;    struct lan *lan;    assert(port_no < b->n_ports);    lan = b->ports[port_no];    if (lan) {        const void *data = pkt->l3;        size_t size = (char *) ofpbuf_tail(pkt) - (char *) data;        int i;        for (i = 0; i < lan->n_conns; i++) {            struct lan_conn *conn = &lan->conns[i];            if (conn->bridge != b || conn->port_no != port_no) {                struct bridge *dst = conn->bridge;                struct bpdu *bpdu = &dst->rxq[dst->rxq_head++ % RXQ_SIZE];                assert(dst->rxq_head - dst->rxq_tail <= RXQ_SIZE);                bpdu->data = xmemdup(data, size);                bpdu->size = size;                bpdu->port_no = conn->port_no;            }        }    }    ofpbuf_delete(pkt);}
开发者ID:AlickHill,项目名称:Lantern,代码行数:27,


示例6: expand_insert

voidexpand_insert(struct expand *expand, struct expandnode *node){	struct expandnode *xn;	if (node->type == EXPAND_USERNAME &&	    expand->parent &&	    expand->parent->type == EXPAND_USERNAME &&	    !strcmp(expand->parent->u.user, node->u.user))		node->sameuser = 1;	if (expand_lookup(expand, node))		return;	xn = xmemdup(node, sizeof *xn, "expand_insert");	xn->rule = expand->rule;	xn->parent = expand->parent;	xn->alias = expand->alias;	if (xn->parent)		xn->depth = xn->parent->depth + 1;	else		xn->depth = 0;	RB_INSERT(expandtree, &expand->tree, xn);	if (expand->queue)		TAILQ_INSERT_TAIL(expand->queue, xn, tq_entry);}
开发者ID:clongeau,项目名称:opensmtpd,代码行数:26,


示例7: os_GetBasename

/** * NAME:    os_GetBasename * PURPOSE: get basename of the file * ARGS:    path - path of the file * RETURN:  basename of the file, allocated in the heap */char *os_GetBasename(char const *path){  int   l;  char const *s;  char const *sp = 0;  if (!path) return xstrdup("");  l = strlen(path);  s = path + l - 1;  for (s = path + l - 1; s >= path; s--) {    if (*s == '/' || *s == '//') {      s++;      break;    } else if (*s == '.' && !sp) {      sp = s;    } else if (*s == ':') {      s++;      break;    }  }  if (s < path) {    s = path;  }  if (s == sp || !sp) {    sp = path + l;  }  return xmemdup(s, sp - s);}
开发者ID:NUOG,项目名称:ejudge,代码行数:36,


示例8: hs_isect_arr

boolhs_isect_arr (struct hs *res, const struct hs *hs, const array_t *a){  const struct hs_vec *v = &hs->list;  array_t tmp[ARRAY_BYTES (hs->len) / sizeof (array_t)];  int pos = -1;  for (int i = 0; i < v->used; i++) {    if (!array_isect (v->elems[i], a, hs->len, tmp)) continue;    pos = i; break;  }  if (pos == -1) return false;  memset (res, 0, sizeof *res);  res->len = hs->len;  struct hs_vec *resv = &res->list;  for (int i = pos; i < v->used; i++) {    if (i == pos) vec_append (resv, xmemdup (tmp, sizeof tmp), false);    else {      array_t *isect = array_isect_a (v->elems[i], a, res->len);      if (!isect) continue;      vec_append (resv, isect, false);    }    struct hs_vec *diff = &v->diff[i], *resd = &resv->diff[resv->used - 1];    for (int j = 0; j < diff->used; j++) {      array_t *isect = array_isect_a (diff->elems[j], a, res->len);      if (!isect) continue;      vec_append (resd, isect, true);    }  }  return true;}
开发者ID:NetSys,项目名称:sts,代码行数:33,


示例9: xSymbolTable_putHelper

void xSymbolTable_putHelper(xSymbolTable* table, char *symbol, xToken* token) {        unsigned int hash = hashString(symbol, table->capacity);    unsigned int i = hash;    unsigned int inc = hash / 2 + 1;    while (table->slot[i].symbol != NULL) {        // Look for slots contains a key that matches symbol.        if (strcmp(table->slot[i].symbol, symbol) == 0) {            break;        }        i =  (i + inc) % table->capacity;    }        if (table->slot[i].symbol != NULL) {        // We found symbol.  Change the value associated with it to token. */        xToken_free(table->slot[i].token);        table->slot[i].token = token;    }    else {        // We reached the slot[] that should contain the new association.         // put the (symbol, token) pair into the slots        // symbol
C++ xmemdupz函数代码示例
C++ xmemcpy函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。