本文整理汇总了C++中bu_calloc函数的典型用法代码示例。如果您正苦于以下问题:C++ bu_calloc函数的具体用法?C++ bu_calloc怎么用?C++ bu_calloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bu_calloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: bn_vlblock_init
struct bn_vlblock *
bn_vlblock_init(struct bu_list *free_vlist_hd, /**< where to get/put free vlists */
int max_ent /**< maximum number of entities to get/put */)
{
struct bn_vlblock *vbp;
size_t i;
if (!BU_LIST_IS_INITIALIZED(free_vlist_hd))
BU_LIST_INIT(free_vlist_hd);
BU_ALLOC(vbp, struct bn_vlblock);
vbp->magic = BN_VLBLOCK_MAGIC;
vbp->free_vlist_hd = free_vlist_hd;
vbp->max = max_ent;
vbp->head = (struct bu_list *)bu_calloc(vbp->max,
sizeof(struct bu_list), "head[]");
vbp->rgb = (long *)bu_calloc(vbp->max,
sizeof(long), "rgb[]");
for (i=0; i < vbp->max; i++) {
vbp->rgb[i] = 0;
BU_LIST_INIT(&(vbp->head[i]));
}
vbp->rgb[0] = 0xFFFF00L; /* Yellow, default */
vbp->rgb[1] = 0xFFFFFFL; /* White */
vbp->nused = 2;
return vbp;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:30,代码来源:vlist.c
示例2: db_add_node_to_full_path
void
db_add_node_to_full_path(struct db_full_path *pp, struct directory *dp)
{
RT_CK_FULL_PATH(pp);
if (pp->fp_maxlen <= 0) {
pp->fp_maxlen = 32;
pp->fp_names = (struct directory **)bu_malloc(
pp->fp_maxlen * sizeof(struct directory *),
"db_full_path array");
pp->fp_bool = (int *)bu_calloc(pp->fp_maxlen, sizeof(int),
"db_full_path bool array");
pp->fp_mat = (matp_t *)bu_calloc(pp->fp_maxlen, sizeof(matp_t),
"db_full_path matrices array");
} else if (pp->fp_len >= pp->fp_maxlen) {
pp->fp_maxlen *= 4;
pp->fp_names = (struct directory **)bu_realloc(
(char *)pp->fp_names,
pp->fp_maxlen * sizeof(struct directory *),
"enlarged db_full_path array");
pp->fp_bool = (int *)bu_realloc(
(char *)pp->fp_bool,
pp->fp_maxlen * sizeof(int),
"enlarged db_full_path bool array");
pp->fp_mat = (matp_t *)bu_realloc(
(char *)pp->fp_mat,
pp->fp_maxlen * sizeof(matp_t),
"enlarged db_full_path matrices array");
}
pp->fp_names[pp->fp_len++] = dp;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
示例3: dup_bot
struct rt_bot_internal *
dup_bot( struct rt_bot_internal *bot_in )
{
struct rt_bot_internal *bot;
size_t i;
RT_BOT_CK_MAGIC( bot_in );
BU_ALLOC(bot, struct rt_bot_internal);
*bot = *bot_in; /* struct copy */
bot->faces = (int *)bu_calloc( bot_in->num_faces*3, sizeof( int ), "bot faces" );
for ( i=0; i<bot_in->num_faces*3; i++ )
bot->faces[i] = bot_in->faces[i];
bot->vertices = (fastf_t *)bu_calloc( bot_in->num_vertices*3, sizeof( fastf_t ), "bot verts" );
for ( i=0; i<bot_in->num_vertices*3; i++ )
bot->vertices[i] = bot_in->vertices[i];
if ( bot_in->thickness ) {
bot->thickness = (fastf_t *)bu_calloc( bot_in->num_faces, sizeof( fastf_t ), "bot thickness" );
for ( i=0; i<bot_in->num_faces; i++ )
bot->thickness[i] = bot_in->thickness[i];
}
if ( bot_in->face_mode ) {
bot->face_mode = bu_bitv_dup( bot_in->face_mode );
}
return bot;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:32,代码来源:g-x3d.c
示例4: rt_arbn_volume
void
rt_arbn_volume(fastf_t *volume, const struct rt_db_internal *ip)
{
struct poly_face *faces;
struct rt_arbn_internal *aip = (struct rt_arbn_internal *)ip->idb_ptr;
size_t i;
*volume = 0.0;
/* allocate array of face structs */
faces = (struct poly_face *)bu_calloc(aip->neqn, sizeof(struct poly_face), "rt_arbn_volume: faces");
for (i = 0; i < aip->neqn; i++) {
/* allocate array of pt structs, max number of verts per faces = (# of faces) - 1 */
faces[i].pts = (point_t *)bu_calloc(aip->neqn - 1, sizeof(point_t), "rt_arbn_volume: pts");
}
rt_arbn_faces_area(faces, aip);
for (i = 0; i < aip->neqn; i++) {
vect_t tmp;
/* calculate volume of pyramid */
VSCALE(tmp, faces[i].plane_eqn, faces[i].area);
*volume += VDOT(faces[i].pts[0], tmp)/3;
}
for (i = 0; i < aip->neqn; i++) {
bu_free((char *)faces[i].pts, "rt_arbn_volume: pts");
}
bu_free((char *)faces, "rt_arbn_volume: faces");
}
开发者ID:kanzure,项目名称:brlcad,代码行数:27,代码来源:arbn.c
示例5: db_argv_to_path
int
db_argv_to_path(struct db_full_path *pp, struct db_i *dbip, int argc, const char *const *argv)
{
struct directory *dp;
int ret = 0;
int i;
RT_CK_DBI(dbip);
/* Make a path structure just big enough */
pp->magic = DB_FULL_PATH_MAGIC;
pp->fp_maxlen = pp->fp_len = argc;
pp->fp_names = (struct directory **)bu_malloc(
pp->fp_maxlen * sizeof(struct directory *),
"db_argv_to_path path array");
pp->fp_bool = (int *)bu_calloc(pp->fp_maxlen, sizeof(int),
"db_argv_to_path bool array");
pp->fp_mat = (matp_t *)bu_calloc(pp->fp_maxlen, sizeof(matp_t),
"db_string_to_path mat array");
for (i = 0; i<argc; i++) {
if ((dp = db_lookup(dbip, argv[i], LOOKUP_NOISY)) == RT_DIR_NULL) {
bu_log("db_argv_to_path() failed on element %d='%s'\n",
i, argv[i]);
ret = -1; /* FAILED */
/* Fall through, storing null dp in this location */
}
pp->fp_names[i] = dp;
}
return ret;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
示例6: db_dup_full_path
void
db_dup_full_path(struct db_full_path *newp, const struct db_full_path *oldp)
{
unsigned int i = 0;
RT_CK_FULL_PATH(newp);
RT_CK_FULL_PATH(oldp);
newp->fp_maxlen = oldp->fp_maxlen;
newp->fp_len = oldp->fp_len;
if (oldp->fp_len <= 0) {
newp->fp_names = (struct directory **)0;
newp->fp_bool = (int *)0;
return;
}
newp->fp_names = (struct directory **)bu_malloc(newp->fp_maxlen * sizeof(struct directory *),
"db_full_path array (duplicate)");
memcpy((char *)newp->fp_names, (char *)oldp->fp_names, newp->fp_len * sizeof(struct directory *));
newp->fp_bool = (int *)bu_malloc(newp->fp_maxlen * sizeof(int),
"db_full_path bool array (duplicate)");
memcpy((char *)newp->fp_bool, (char *)oldp->fp_bool, newp->fp_len * sizeof(int));
newp->fp_mat = (matp_t *)bu_calloc(newp->fp_maxlen, sizeof(matp_t),
"db_full_path mat array (duplicate)");
for (i = 0; i < newp->fp_len; i++) {
if (oldp->fp_mat[i]) {
newp->fp_mat[i] = (matp_t)bu_calloc(1, sizeof(mat_t), "transformation matrix");
MAT_COPY(newp->fp_mat[i], oldp->fp_mat[i]);
}
}
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
示例7: rt_arbn_centroid
void
rt_arbn_centroid(point_t *cent, const struct rt_db_internal *ip)
{
struct poly_face *faces;
struct rt_arbn_internal *aip = (struct rt_arbn_internal *)ip->idb_ptr;
size_t i;
point_t arbit_point = VINIT_ZERO;
fastf_t volume = 0.0;
*cent[0] = 0.0;
*cent[1] = 0.0;
*cent[2] = 0.0;
if (cent == NULL)
return;
/* allocate array of face structs */
faces = (struct poly_face *)bu_calloc(aip->neqn, sizeof(struct poly_face), "rt_arbn_centroid: faces");
for (i = 0; i < aip->neqn; i++) {
/* allocate array of pt structs, max number of verts per faces = (# of faces) - 1 */
faces[i].pts = (point_t *)bu_calloc(aip->neqn - 1, sizeof(point_t), "rt_arbn_centroid: pts");
}
rt_arbn_faces_area(faces, aip);
for (i = 0; i < aip->neqn; i++) {
bn_polygon_centroid(&faces[i].cent, faces[i].npts, (const point_t *) faces[i].pts);
VADD2(arbit_point, arbit_point, faces[i].cent);
}
VSCALE(arbit_point, arbit_point, (1/aip->neqn));
for (i = 0; i < aip->neqn; i++) {
vect_t tmp = VINIT_ZERO;
/* calculate volume */
VSCALE(tmp, faces[i].plane_eqn, faces[i].area);
faces[i].vol_pyramid = (VDOT(faces[i].pts[0], tmp)/3);
volume += faces[i].vol_pyramid;
/*Vector from arbit_point to centroid of face, results in h of pyramid */
VSUB2(faces[i].cent_pyramid, faces[i].cent, arbit_point);
/*centroid of pyramid is 1/4 up from the bottom */
VSCALE(faces[i].cent_pyramid, faces[i].cent_pyramid, 0.75f);
/* now cent_pyramid is back in the polyhedron */
VADD2(faces[i].cent_pyramid, faces[i].cent_pyramid, arbit_point);
/* weight centroid of pyramid by pyramid's volume */
VSCALE(faces[i].cent_pyramid, faces[i].cent_pyramid, faces[i].vol_pyramid);
/* add cent_pyramid to the centroid of the polyhedron */
VADD2(*cent, *cent, faces[i].cent_pyramid);
}
/* reverse the weighting */
VSCALE(*cent, *cent, (1/volume));
for (i = 0; i < aip->neqn; i++) {
bu_free((char *)faces[i].pts, "rt_arbn_centroid: pts");
}
bu_free((char *)faces, "rt_arbn_centroid: faces");
}
开发者ID:kanzure,项目名称:brlcad,代码行数:54,代码来源:arbn.c
示例8: dup_bot
/* duplicate bot */
struct rt_bot_internal *
dup_bot(struct rt_bot_internal *bot_in)
{
struct rt_bot_internal *bot;
size_t i;
RT_BOT_CK_MAGIC(bot_in);
BU_ALLOC(bot, struct rt_bot_internal);
bot->magic = bot_in->magic;
bot->mode = bot_in->mode;
bot->orientation = bot_in->orientation;
bot->bot_flags = bot_in->bot_flags;
bot->num_vertices = bot_in->num_vertices;
bot->num_faces = bot_in->num_faces;
bot->num_normals = bot_in->num_normals;
bot->num_face_normals = bot_in->num_face_normals;
bot->faces = (int *)bu_calloc(bot_in->num_faces * 3, sizeof(int), "bot faces");
for (i = 0; i < bot_in->num_faces * 3; i++) {
bot->faces[i] = bot_in->faces[i];
}
bot->vertices = (fastf_t *)bu_calloc(bot_in->num_vertices * 3, sizeof(fastf_t), "bot verts");
for (i = 0; i < bot_in->num_vertices * 3; i++) {
bot->vertices[i] = bot_in->vertices[i];
}
if ((bot_in->bot_flags & RT_BOT_PLATE) || (bot_in->bot_flags & RT_BOT_PLATE_NOCOS)) {
if (bot_in->thickness) {
bot->thickness = (fastf_t *)bu_calloc(bot_in->num_faces, sizeof(fastf_t), "bot thickness");
for (i = 0; i < bot_in->num_faces; i++) {
bot->thickness[i] = bot_in->thickness[i];
}
} else {
bu_bomb("dup_bot(): flag should not say plate but thickness is null\n");
}
}
if (bot_in->face_mode) {
bot->face_mode = bu_bitv_dup(bot_in->face_mode);
}
if (bot_in->bot_flags & RT_BOT_HAS_SURFACE_NORMALS) {
bot->num_normals = bot_in->num_normals;
bot->normals = (fastf_t *)bu_calloc(bot_in->num_normals * 3, sizeof(fastf_t), "BOT normals");
bot->face_normals = (int *)bu_calloc(bot_in->num_faces * 3, sizeof(int), "BOT face normals");
memcpy(bot->face_normals, bot_in->face_normals, bot_in->num_faces * 3 * sizeof(int));
}
return bot;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:54,代码来源:vrml_write.c
示例9: Get_outer_shell
struct shell *
Get_outer_shell(struct nmgregion *r, int entityno)
{
int sol_num; /* IGES solid type number */
int no_of_faces; /* Number of faces in shell */
int face_count = 0; /* Number of faces actually made */
int *face_de; /* Directory sequence numbers for faces */
int *face_orient; /* Orientation of faces */
int face;
struct shell *s; /* NMG shell */
struct faceuse **fu; /* list of faceuses */
/* Acquiring Data */
if (dir[entityno]->param <= pstart) {
bu_log("Illegal parameter pointer for entity D%07d (%s)\n" ,
dir[entityno]->direct, dir[entityno]->name);
return 0;
}
Readrec(dir[entityno]->param);
Readint(&sol_num, "");
Readint(&no_of_faces, "");
face_de = (int *)bu_calloc(no_of_faces, sizeof(int), "Get_outer_shell face DE's");
face_orient = (int *)bu_calloc(no_of_faces, sizeof(int), "Get_outer_shell orients");
fu = (struct faceuse **)bu_calloc(no_of_faces, sizeof(struct faceuse *), "Get_outer_shell faceuses ");
for (face = 0; face < no_of_faces; face++) {
Readint(&face_de[face], "");
Readint(&face_orient[face], "");
}
s = nmg_msv(r);
for (face = 0; face < no_of_faces; face++) {
fu[face_count] = Add_face_to_shell(s, (face_de[face]-1)/2, face_orient[face]);
if (fu[face_count] != (struct faceuse *)NULL)
face_count++;
}
nmg_gluefaces(fu, face_count, &tol);
bu_free((char *)fu, "Get_outer_shell: faceuse list");
bu_free((char *)face_de, "Get_outer_shell: face DE's");
bu_free((char *)face_orient, "Get_outer_shell: face orients");
return s;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:49,代码来源:get_outer_shell.c
示例10: generate_edge_list
HIDDEN struct halfedge *
generate_edge_list(const struct rt_bot_internal *bot)
{
const size_t num_edges = 3 * bot->num_faces;
struct halfedge *edge_list;
size_t face_index, edge_index;
edge_list = (struct halfedge *)bu_calloc(num_edges, sizeof(struct halfedge),
"edge_list");
for (face_index = 0, edge_index = 0; face_index < bot->num_faces;
++face_index) {
const int *face = &bot->faces[face_index * 3];
int success = set_edge(&edge_list[edge_index++], face[0], face[1])
&& set_edge(&edge_list[edge_index++], face[1], face[2])
&& set_edge(&edge_list[edge_index++], face[2], face[0]);
if (!success) {
bu_free(edge_list, "edge_list");
return NULL;
}
}
qsort(edge_list, num_edges, sizeof(struct halfedge), halfedge_compare);
return edge_list;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:28,代码来源:bot_solidity.c
示例11: db_alloc_directory_block
void
db_alloc_directory_block(struct resource *resp)
{
struct directory *dp;
size_t bytes;
RT_CK_RESOURCE(resp);
BU_CK_PTBL(&resp->re_directory_blocks);
BU_ASSERT_PTR(resp->re_directory_hd, ==, NULL);
/* Get a BIG block */
bytes = (size_t)bu_malloc_len_roundup(1024*sizeof(struct directory));
dp = (struct directory *)bu_calloc(1, bytes, "re_directory_blocks from db_alloc_directory_block() " BU_FLSTR);
/* Record storage for later */
bu_ptbl_ins(&resp->re_directory_blocks, (long *)dp);
while (bytes >= sizeof(struct directory)) {
dp->d_magic = RT_DIR_MAGIC;
dp->d_forw = resp->re_directory_hd;
resp->re_directory_hd = dp;
dp++;
bytes -= sizeof(struct directory);
}
}
开发者ID:kanzure,项目名称:brlcad,代码行数:26,代码来源:db_alloc.c
示例12: automatic_test
/* Test against basename UNIX tool */
void
automatic_test(const char *input)
{
char buf_input[1000];
char *ans = NULL;
char *res = (char *)bu_calloc(strlen(buf_input), sizeof(char), "automatic_test res");
#ifdef HAVE_BASENAME
if (input)
bu_strlcpy(buf_input, input, strlen(input)+1);
/* build UNIX 'basename' command */
if (!input)
ans = basename(NULL);
else
ans = basename(buf_input);
if (!input)
bu_basename(res, NULL);
else
bu_basename(res, buf_input);
if (BU_STR_EQUAL(res, ans))
printf("%24s -> %24s [PASSED]\n", input, res);
else
bu_exit(EXIT_FAILURE, "%24s -> %24s (should be: %s) [FAIL]\n", input, res, ans);
bu_free(res, NULL);
#else
printf("BASENAME not available on this platform\n");
#endif
/* FIXME: this does not functionally halt */
}
开发者ID:kanzure,项目名称:brlcad,代码行数:35,代码来源:bu_basename.c
示例13: rt_superell_export4
int
rt_superell_export4(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_superell_internal *tip;
union record *rec;
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_SUPERELL) return -1;
tip = (struct rt_superell_internal *)ip->idb_ptr;
RT_SUPERELL_CK_MAGIC(tip);
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = sizeof(union record);
ep->ext_buf = (uint8_t *)bu_calloc(1, ep->ext_nbytes, "superell external");
rec = (union record *)ep->ext_buf;
rec->s.s_id = ID_SOLID;
rec->s.s_type = SUPERELL;
/* NOTE: This also converts to dbfloat_t */
VSCALE(&rec->s.s_values[0], tip->v, local2mm);
VSCALE(&rec->s.s_values[3], tip->a, local2mm);
VSCALE(&rec->s.s_values[6], tip->b, local2mm);
VSCALE(&rec->s.s_values[9], tip->c, local2mm);
printf("SUPERELL: %g %g\n", tip->n, tip->e);
rec->s.s_values[12] = tip->n;
rec->s.s_values[13] = tip->e;
return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:34,代码来源:superell.c
示例14: parse_args
/** @if no
* @endif
* @brief Parse command line flags.
*
* This routine handles parsing of all command line options.
*
* @param ac count of arguments
* @param av array of pointers to null-terminated strings
* @return index into av of first argument past options (new ac value)
*/
int parse_args(int ac, char *av[])
{
int c;
char *strrchr();
char *tmp_basename = (char *)bu_calloc(strlen(av[0]), sizeof(char), "parse_args");;
/* Turn off bu_getopt's error messages */
bu_opterr = 0;
/* get all the option flags from the command line */
while ((c=bu_getopt(ac, av, options)) != -1) {
switch (c) {
case 'd':
debug = strtol(bu_optarg, NULL, 16);
break;
case '?':
case 'h':
default:
bu_basename(tmp_basename, av[0]);
usage(tmp_basename, "Bad or help flag specified\n");
break;
}
}
bu_free(tmp_basename, "tmp_basename free");
return bu_optind;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:36,代码来源:walk_example.c
示例15: rt_xxx_export5
/**
* Export an XXX from internal form to external format. Note that
* this means converting all integers to Big-Endian format and
* floating point data to IEEE double.
*
* Apply the transformation to mm units as well.
*/
int
rt_xxx_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_xxx_internal *xxx_ip;
/* must be double for import and export */
double vec[ELEMENTS_PER_VECT];
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_XXX) return -1;
xxx_ip = (struct rt_xxx_internal *)ip->idb_ptr;
RT_XXX_CK_MAGIC(xxx_ip);
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
ep->ext_buf = (void *)bu_calloc(1, ep->ext_nbytes, "xxx external");
/* Since libwdb users may want to operate in units other than mm,
* we offer the opportunity to scale the solid (to get it into mm)
* on the way out.
*/
VSCALE(vec, xxx_ip->v, local2mm);
/* Convert from internal (host) to database (network) format */
bu_cv_htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT);
return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:36,代码来源:xxx.c
示例16: f_red
/*
*
* Get editing string and call ged_red
*/
int
f_red(ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const char *argv[])
{
const char **av;
struct bu_vls editstring = BU_VLS_INIT_ZERO;
CHECK_DBI_NULL;
if (argc != 2) {
Tcl_Eval(interpreter, "help red");
return TCL_ERROR;
}
get_editor_string(&editstring);
av = (const char **)bu_calloc(4, sizeof(char *), "f_red: av");
av[0] = argv[0];
av[1] = "-E";
av[2] = bu_vls_addr(&editstring);
av[3] = argv[1];
if ( ged_red(gedp, 4, (const char **)av) == GED_ERROR ) {
Tcl_AppendResult(interpreter, "Error: ", bu_vls_addr(gedp->ged_result_str), (char *)NULL);
} else {
Tcl_AppendResult(interpreter, bu_vls_addr(gedp->ged_result_str), (char *)NULL);
}
bu_vls_free(&editstring);
bu_free((void *)av, "f_red: av");
return TCL_OK;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:36,代码来源:utility1.c
示例17: init_list
/**
* initialize the name list used for stashing destination names
*/
static void
init_list(struct nametbl *l, size_t s)
{
size_t i, j;
l->names = (struct name *)bu_calloc(10, sizeof(struct name), "alloc l->names");
for (i = 0; i < 10; i++) {
bu_vls_init(&l->names[i].src);
l->names[i].dest = (struct bu_vls *)bu_calloc(s, sizeof(struct bu_vls), "alloc l->names.dest");
for (j = 0; j < s; j++)
bu_vls_init(&l->names[i].dest[j]);
}
l->name_size = s;
l->names_len = 10;
l->names_used = 0;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:19,代码来源:clone.c
示例18: bu_b64_decode_block
int
bu_b64_decode_block(char **output, const char *input, int len)
{
/* Calculate size of output needed and calloc the memory */
int cnt = 0;
char* c;
bu_b64_decodestate s;
if (!output) return -1;
*output = (char *)bu_calloc(((int)(3*len/4) + 4), 8, "Calloc b64 decoding buffer");
c = *output;
/*---------- START DECODING ----------*/
/* initialise the decoder state */
bu_b64_init_decodestate(&s);
/* decode the input data */
cnt = bu_b64_decode_block_internal(input, len, c, &s);
c += cnt;
/* note: there is no bu_b64_decode_blockend! */
/*---------- STOP DECODING ----------*/
/* we want to print the decoded data, so null-terminate it: */
*c = '\0';
return cnt;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:25,代码来源:b64.c
示例19: bu_realpath
char *
bu_realpath(const char *path, char *resolved_path)
{
if (!resolved_path)
resolved_path = (char *) bu_calloc(MAXPATHLEN, sizeof(char), "resolved_path alloc");
#if defined(HAVE_WORKING_REALPATH_FUNCTION)
{
char *dirpath = NULL;
dirpath = realpath(path, resolved_path);
if (!dirpath) {
/* if path lookup failed, resort to simple copy */
bu_strlcpy(resolved_path, path, (size_t)MAXPATHLEN);
}
}
#elif defined(HAVE_GETFULLPATHNAME)
/* Best solution currently available for Windows
* See https://www.securecoding.cert.org/confluence/display/seccode/FIO02-C.+Canonicalize+path+names+originating+from+untrusted+sources */
GetFullPathName(path, MAXPATHLEN, resolved_path, NULL);
#else
/* Last resort - if NOTHING is defined, do a simple copy */
bu_strlcpy(resolved_path, path, (size_t)MAXPATHLEN);
#endif
return resolved_path;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:26,代码来源:realpath.c
示例20: bu_b64_encode_block
char *
bu_b64_encode_block(const char *input, int len)
{
/* Calculate size of output needed and calloc the memory */
char *output = (char *)bu_calloc((((int)(4*len/3)) + 4), 8, "Calloc b64 buffer");
char *c = output;
int cnt = 0;
bu_b64_encodestate s;
/*---------- START ENCODING ----------*/
/* initialise the encoder state */
bu_b64_init_encodestate(&s);
/* gather data from the input and send it to the output */
cnt = bu_b64_encode_block_internal(input, len, c, &s);
c += cnt;
/* since we have encoded all of the input string we intend
* to encode, we know that there is no more input data;
* finalise the encoding */
cnt = bu_b64_encode_blockend(c, &s);
c += cnt;
/*---------- STOP ENCODING ----------*/
/* we want to print the encoded data, so null-terminate it: */
*c = '\0';
return output;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:27,代码来源:b64.c
注:本文中的bu_calloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论