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


C++ pcalloc函数代码示例

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


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

示例1: pcalloc

/* The difference between this function, and pr_cmd_alloc(), is that this
 * allocates the cmd_rec directly from the given pool, whereas pr_cmd_alloc()
 * will allocate a subpool from the given pool, and allocate its cmd_rec
 * from the subpool.  This means that pr_cmd_alloc()'s cmd_rec's can be
 * subsequently destroyed easily; this function's cmd_rec's will be destroyed
 * when the given pool is destroyed.
 */
static cmd_rec *make_cmd(pool *cp, int argc, ...) {
  va_list args;
  cmd_rec *c;
  pool *sub_pool;

  c = pcalloc(cp, sizeof(cmd_rec));

  c->argc = argc;
  c->stash_index = -1;

  if (argc) {
    register unsigned int i;

    c->argv = pcalloc(cp, sizeof(void *) * (argc + 1));

    va_start(args, argc);

    for (i = 0; i < argc; i++) {
      c->argv[i] = (void *) va_arg(args, char *);
    }

    va_end(args);

    c->argv[argc] = NULL;
  }

  /* Make sure we provide pool and tmp_pool for the consumers. */
  sub_pool = make_sub_pool(cp);
  c->pool = c->tmp_pool = sub_pool;

  return c;
}
开发者ID:Distrotech,项目名称:proftpd,代码行数:39,代码来源:auth.c

示例2: pcalloc

pr_buffer_t *pr_netio_buffer_alloc(pr_netio_stream_t *nstrm) {
  size_t bufsz;
  pr_buffer_t *pbuf = NULL;

  if (nstrm == NULL) {
    errno = EINVAL;
    return NULL;
  }

  pbuf = pcalloc(nstrm->strm_pool, sizeof(pr_buffer_t));

  /* Allocate a buffer. */
  bufsz = pr_config_get_server_xfer_bufsz(nstrm->strm_mode);
  pbuf->buf = pcalloc(nstrm->strm_pool, bufsz);
  pbuf->buflen = bufsz;

  /* Position the offset at the start of the buffer, and set the
   * remaining bytes value accordingly.
   */
  pbuf->current = pbuf->buf;
  pbuf->remaining = bufsz;

  /* Add this buffer to the given stream. */
  nstrm->strm_buf = pbuf;

  return pbuf;
}
开发者ID:Nubisa,项目名称:JXPanel,代码行数:27,代码来源:netio.c

示例3: pc_point_make

PCPOINT *
pc_point_make(const PCSCHEMA *s)
{
	size_t sz;
	PCPOINT *pt;

	if ( ! s )
	{
		pcerror("null schema passed into pc_point_make");
		return NULL;
	}

	/* Width of the data area */
	sz = s->size;
	if ( ! sz )
	{
		pcerror("invalid size calculation in pc_point_make");
		return NULL;
	}

	/* Make our own data area */
	pt = pcalloc(sizeof(PCPOINT));
	pt->data = pcalloc(sz);

	/* Set up basic info */
	pt->schema = s;
	pt->readonly = PC_FALSE;
	return pt;
};
开发者ID:Shankarsetty,项目名称:pointcloud,代码行数:29,代码来源:pc_point.c

示例4: pc_point_from_double_array

PCPOINT *
pc_point_from_double_array(const PCSCHEMA *s, double *array, uint32_t nelems)
{
	int i;
	PCPOINT *pt;

	if ( ! s )
	{
		pcerror("null schema passed into pc_point_from_double_array");
		return NULL;
	}

	if ( s->ndims != nelems )
	{
		pcerror("number of elements in schema and array differ in pc_point_from_double_array");
		return NULL;
	}

	/* Reference the external data */
	pt = pcalloc(sizeof(PCPOINT));
	pt->data = pcalloc(s->size);
	pt->schema = s;
	pt->readonly = PC_FALSE;

	for ( i = 0; i < nelems; i++ )
	{
		if ( PC_FAILURE == pc_point_set_double_by_index(pt, i, array[i]) )
		{
			pcerror("failed to write value into dimension %d in pc_point_from_double_array", i);
			return NULL;
		}
	}

	return pt;
}
开发者ID:Shankarsetty,项目名称:pointcloud,代码行数:35,代码来源:pc_point.c

示例5: pcalloc

char *pr_utf8_encode(pool *p, const char *in, size_t inlen, size_t *outlen) {
#ifdef HAVE_ICONV_H
  size_t inbuflen, outbuflen;
  char *inbuf, outbuf[PR_TUNABLE_PATH_MAX*2], *res;

  if (!p || !in || !outlen) {
    errno = EINVAL;
    return NULL;
  }

  if (encode_conv == (iconv_t) -1) {
    errno = EPERM;
    return NULL;
  }

  inbuf = pcalloc(p, inlen);
  memcpy(inbuf, in, inlen);
  inbuflen = inlen;

  outbuflen = sizeof(outbuf);

  if (utf8_convert(encode_conv, inbuf, &inbuflen, outbuf, &outbuflen) < 0)
    return NULL;

  *outlen = sizeof(outbuf) - outbuflen;
  res = pcalloc(p, *outlen);
  memcpy(res, outbuf, *outlen);

  return res;
#else
  pr_trace_msg("utf8", 1, "missing iconv support, no UTF8 encoding possible");
  return pstrdup(p, in);
#endif /* !HAVE_ICONV_H */
}
开发者ID:Nakor78,项目名称:proftpd,代码行数:34,代码来源:utf8.c

示例6: pc_patch_dimensional_compress

PCPATCH_DIMENSIONAL *
pc_patch_dimensional_compress(const PCPATCH_DIMENSIONAL *pdl, PCDIMSTATS *pds)
{
	int i;
	int ndims = pdl->schema->ndims;
	PCPATCH_DIMENSIONAL *pdl_compressed;

	assert(pdl);
	assert(pdl->schema);

	if ( ! pds )
		pds = pc_dimstats_make(pdl->schema);

	/* Still sampling, update stats */
	if ( pds->total_points < PCDIMSTATS_MIN_SAMPLE )
		pc_dimstats_update(pds, pdl);

	pdl_compressed = pcalloc(sizeof(PCPATCH_DIMENSIONAL));
	memcpy(pdl_compressed, pdl, sizeof(PCPATCH_DIMENSIONAL));
	pdl_compressed->bytes = pcalloc(ndims*sizeof(PCBYTES));

	/* Compress each dimension as dictated by stats */
	for ( i = 0; i < ndims; i++ )
	{
		pdl_compressed->bytes[i] = pc_bytes_encode(pdl->bytes[i], pds->stats[i].recommended_compression);
	}

	return pdl_compressed;
}
开发者ID:Remi-C,项目名称:pointcloud,代码行数:29,代码来源:pc_patch_dimensional.c

示例7: PR_ERROR_MSG

/*
 * _build_data: both cmd_select and cmd_procedure potentially
 *  return data to mod_sql; this function builds a modret to return
 *  that data.  This is Postgres specific; other backends may choose 
 *  to do things differently.
 */
static modret_t *_build_data(cmd_rec *cmd, db_conn_t *conn) {
  PGresult *result = NULL;
  sql_data_t *sd = NULL;
  char **data = NULL;
  int index = 0;
  int field = 0;
  int row =0;

  if (!conn) 
    return PR_ERROR_MSG(cmd, MOD_SQL_POSTGRES_VERSION, "badly formed request");

  result = conn->result;

  sd = (sql_data_t *) pcalloc(cmd->tmp_pool, sizeof(sql_data_t));
  sd->rnum = (unsigned long) PQntuples(result);
  sd->fnum = (unsigned long) PQnfields(result);

  data = (char **) pcalloc(cmd->tmp_pool, sizeof(char *) * 
			    ((sd->rnum * sd->fnum) + 1));
  
  for (row = 0; row < sd->rnum; row++) {
    for (field = 0; field < sd->fnum; field++) {
      data[index++] = pstrdup(cmd->tmp_pool, PQgetvalue(result, row, field));
    }
  }
  data[index] = NULL;

  sd->data = data;

  return mod_create_data( cmd, (void *) sd );
}
开发者ID:Distrotech,项目名称:proftpd,代码行数:37,代码来源:mod_sql_postgres.c

示例8: pool_create

void *new_obj(pool_t *mpool, size_t sz)
{
    pool_t *mp = mpool;
    obj_t *ob = NULL;

    if (mp == NULL) {
        mp = pool_create(G_MPOOL_SIZE);
        if (mp == NULL) {
            return NULL;
        }

        ob = (obj_t *)pcalloc(mp, sz);
        if (ob == NULL) {
            pool_destroy(mp);
            return NULL;
        }   

        ob->new_mp_flag = 1;
    } else {
        ob = pcalloc(mp, sz);
        if (ob == NULL) {
            return NULL;
        }   

        ob->new_mp_flag = 0;
    }   

    ob->mpool = mp; 
    return ob;
}
开发者ID:joerong666,项目名称:hidb,代码行数:30,代码来源:obj.c

示例9: parse_cgi

int
parse_cgi(epoll_cgi_t *cgi)
{
	list_buffer *cgi_data, *send;
	buffer *b;
	char *p;
	int count;
	buffer *header, *out, *tmp;

	cgi_data = cgi->cgi_data;
	if(cgi_data == NULL || cgi_data->b == NULL || cgi_data->b->ptr == NULL || cgi_data->b->size == 0) return 0;
	b = cgi_data->b;
	send = (list_buffer *) pcalloc(cgi->con->p, sizeof(list_buffer));
	header = (buffer *) pcalloc(cgi->con->p, sizeof(buffer));

	cgi->con->out->status_code = HTTP_OK;
	p = strstr(b->ptr,"\n\n");
	if(p != NULL && (p-b->ptr) < b->size) {
		buffer_n_to_lower(b, (p-b->ptr)+1);
		header->ptr = b->ptr;
		header->size = (p-b->ptr) + 2;
		
		tmp = (buffer *) pcalloc(cgi->con->p, sizeof(buffer));
		buffer_find_str(header, tmp, "content-type:");
		if(tmp->ptr == NULL) {
			send_bad_gateway(cgi->con->fd);
			return 1;
		}
		p = tmp->ptr + tmp->size;
		while(*p == ' ') p++;

	
		tmp->ptr = p;
		p = strchr(p, '\n');
		
		count = p - tmp->ptr ;
		if(*(p-1) != '\r' ) count++;
		tmp->size = count;

		cgi->con->out->content_type = buffer_create_size(cgi->con->p, count);
		cgi->con->out->content_type->size = count;
		strncpy(cgi->con->out->content_type->ptr, tmp->ptr, count -1);
		cgi->con->out->content_type->ptr[count-1] = 0;

		out = (buffer *)pcalloc(cgi->con->p, sizeof(buffer));
		out->ptr = header->ptr + header->size;
		out->size = b->size - header->size;

		send->b = out;
		send->next = cgi_data->next;
		cgi->out = send; 

		


	}
	

}
开发者ID:rentiansheng,项目名称:rhttp,代码行数:59,代码来源:http_request.c

示例10: bytebuffer_new

static bytebuffer_t *
bytebuffer_new(void)
{
    bytebuffer_t *bb = pcalloc(sizeof(bytebuffer_t));
    bb->sz = 1024;
    bb->buf = pcalloc(bb->sz*sizeof(uint8_t));
    bb->ptr = bb->buf;
}
开发者ID:gijs,项目名称:pointcloud,代码行数:8,代码来源:pc_util.c

示例11: pc_bitmap_new

PCBITMAP *
pc_bitmap_new(uint32_t npoints)
{
	PCBITMAP *map = pcalloc(sizeof(PCBITMAP));
	map->map = pcalloc(sizeof(uint8_t)*npoints);
	map->npoints = npoints;
	map->nset = 0;
	return map;
}
开发者ID:ghelobytes,项目名称:pointcloud,代码行数:9,代码来源:pc_filter.c

示例12: pc_pointlist_make

PCPOINTLIST *
pc_pointlist_make(uint32_t npoints)
{
	PCPOINTLIST *pl = pcalloc(sizeof(PCPOINTLIST));
	pl->points = pcalloc(sizeof(PCPOINT*) * npoints);
	pl->maxpoints = npoints;
	pl->npoints = 0;
	pl->mem = NULL;
	return pl;
}
开发者ID:LI3DS,项目名称:pointcloud,代码行数:10,代码来源:pc_pointlist.c

示例13: pc_patch_dimensional_clone

PCPATCH_DIMENSIONAL *
pc_patch_dimensional_clone(const PCPATCH_DIMENSIONAL *patch)
{
	PCPATCH_DIMENSIONAL *pdl = pcalloc(sizeof(PCPATCH_DIMENSIONAL));
	memcpy(pdl, patch, sizeof(PCPATCH_DIMENSIONAL));
	pdl->bytes = pcalloc(patch->schema->ndims * sizeof(PCBYTES));
	pdl->npoints = 0;
	pdl->stats = NULL;
	return pdl;
}
开发者ID:Remi-C,项目名称:pointcloud,代码行数:10,代码来源:pc_patch_dimensional.c

示例14: pc_pointlist_make

PCPOINTLIST *
pc_pointlist_make(uint32_t npoints)
{
	PCPOINTLIST *pl = pcalloc(sizeof(PCPOINTLIST));
	pl->points = pcalloc(sizeof(PCPOINT*) * npoints);
	pl->maxpoints = npoints;
	pl->npoints = 0;
	pl->readonly = PC_FALSE;
	return pl;
}
开发者ID:Remi-C,项目名称:pointcloud,代码行数:10,代码来源:pc_pointlist.c

示例15: pc_schema_new

static PCSCHEMA*
pc_schema_new(uint32_t ndims)
{
	PCSCHEMA *pcs = pcalloc(sizeof(PCSCHEMA));
	pcs->dims = pcalloc(sizeof(PCDIMENSION*) * ndims);	
	pcs->namehash = create_string_hashtable();
	pcs->ndims = ndims;
	pcs->x_position = -1;
	pcs->y_position = -1;
	return pcs;
}
开发者ID:kjartab,项目名称:pointcloud,代码行数:11,代码来源:pc_schema.c


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