本文整理汇总了C++中dt_free函数的典型用法代码示例。如果您正苦于以下问题:C++ dt_free函数的具体用法?C++ dt_free怎么用?C++ dt_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dtop_meminfo_poll
/**
* @brief Stores the data collected from a "/proc/meminfo"
*
* @param dpg Struct that polled data is added to.
* @return DTOP_POLL_IO_ERR - Poll of dpg unsuccessful.
* @return DTOP_POLL_OK - Poll of dpg successful.
*/
int dtop_meminfo_poll(struct dtop_data_point_gatherer *dpg)
{
char *data;
int *line_len = malloc(sizeof(int) *
((struct dtop_meminfo_vars *)
(dpg->priv))->line_count);
int read;
struct dt_procdict dict;
int i, j, n, sum;
read = dt_read_file(dpg->file, &data, DTOP_MEM_SIZE);
if (read == 0 || data == 0)
return DTOP_POLL_IO_ERR;
sum = 0;
/* Assigns each line read from the file, a length */
for (n = 0; n < ((struct dtop_meminfo_vars *)
(dpg->priv))->line_count; n++) {
line_len[n] = dt_read_line(((struct dtop_meminfo_vars *)
(dpg->priv))->line[n],
DTOP_MEM_LINE, data,
DTOP_MEM_SIZE, sum);
if (n <= (((struct dtop_meminfo_vars *)
(dpg->priv))->line_count - 1)) {
sum += (line_len[n] + 1);
}
}
/* Stores dp names and values in dictionary */
for (i = 0; i < dpg->data_points_len; i++)
dt_meminfo_parse(((struct dtop_meminfo_vars *)
(dpg->priv))->line[i], line_len[i], i, &dict);
/* Assigns the dp value to the dp struct */
for (j = 0; j < dpg->data_points_len; j++) {
i = dt_find_dict_idx(dpg->data_points[j].name, &dict);
if (i >= 0 && i < dict.max) {
sscanf(dict.val[i], "%" PRIu64,
&(dpg->data_points[i].data.d_ulong));
dpg->data_points[i].data.d_ulong *= 1024;
if (dpg->data_points[i].
initial_data_populated == NOT_POPULATED) {
dpg->data_points[i].initial_data.d_ulong
= dpg->data_points[i].data.d_ulong;
dpg->data_points[i].initial_data_populated
= POPULATED;
}
}
}
dt_free(&data);
free(line_len);
return DTOP_POLL_OK;
}
示例2: dt_dof_fini
void
dt_dof_fini(dtrace_hdl_t *dtp)
{
dt_dof_t *ddo = &dtp->dt_dof;
dt_free(dtp, ddo->ddo_xlimport);
dt_free(dtp, ddo->ddo_xlexport);
dt_buf_destroy(dtp, &ddo->ddo_secs);
dt_buf_destroy(dtp, &ddo->ddo_strs);
dt_buf_destroy(dtp, &ddo->ddo_ldata);
dt_buf_destroy(dtp, &ddo->ddo_udata);
dt_buf_destroy(dtp, &ddo->ddo_probes);
dt_buf_destroy(dtp, &ddo->ddo_args);
dt_buf_destroy(dtp, &ddo->ddo_offs);
dt_buf_destroy(dtp, &ddo->ddo_enoffs);
dt_buf_destroy(dtp, &ddo->ddo_rels);
dt_buf_destroy(dtp, &ddo->ddo_xlms);
}
示例3: dtrace_getopt_dof
void *
dtrace_getopt_dof(dtrace_hdl_t *dtp)
{
dof_hdr_t *dof;
dof_sec_t *sec;
dof_optdesc_t *dofo;
int i, nopts = 0, len = sizeof (dof_hdr_t) +
roundup(sizeof (dof_sec_t), sizeof (uint64_t));
for (i = 0; i < DTRACEOPT_MAX; i++) {
if (dtp->dt_options[i] != DTRACEOPT_UNSET)
nopts++;
}
len += sizeof (dof_optdesc_t) * nopts;
if ((dof = dt_zalloc(dtp, len)) == NULL ||
dof_hdr(dtp, DOF_VERSION, dof) != 0) {
dt_free(dtp, dof);
return (NULL);
}
dof->dofh_secnum = 1; /* only DOF_SECT_OPTDESC */
dof->dofh_loadsz = len;
dof->dofh_filesz = len;
/*
* Fill in the option section header...
*/
sec = (dof_sec_t *)((uintptr_t)dof + sizeof (dof_hdr_t));
sec->dofs_type = DOF_SECT_OPTDESC;
sec->dofs_align = sizeof (uint64_t);
sec->dofs_flags = DOF_SECF_LOAD;
sec->dofs_entsize = sizeof (dof_optdesc_t);
dofo = (dof_optdesc_t *)((uintptr_t)sec +
roundup(sizeof (dof_sec_t), sizeof (uint64_t)));
sec->dofs_offset = (uintptr_t)dofo - (uintptr_t)dof;
sec->dofs_size = sizeof (dof_optdesc_t) * nopts;
for (i = 0; i < DTRACEOPT_MAX; i++) {
if (dtp->dt_options[i] == DTRACEOPT_UNSET)
continue;
dofo->dofo_option = i;
dofo->dofo_strtab = DOF_SECIDX_NONE;
dofo->dofo_value = dtp->dt_options[i];
dofo++;
}
return (dof);
}
示例4: dtop_meminfo_search
/**
* @brief Scans "/proc/meminfo in order to autodetect dps.
*
* Searches through "/proc/meminfo" file for all available data
* points to create as dp structs.
*
* @param storage dtop_meminfo_vars struct where relevant variables are stored.
*/
int dtop_meminfo_search(struct dtop_meminfo_vars *storage)
{
int i, k, n, sum;
char *data;
int *line_len = malloc(sizeof(int) * storage->line_count);
int read;
struct dt_procdict dict;
struct dtop_data_point *data_points;
storage->line = malloc(storage->line_count * sizeof(*storage->line));
for (i = 0; i < storage->line_count; i++)
storage->line[i] = malloc(sizeof(char) * DTOP_MEM_LINE);
read = dt_read_file("/proc/meminfo", &data, DTOP_MEM_SIZE);
if (read == 0 || data == 0)
return DTOP_POLL_IO_ERR;
sum = 0;
/* Assigns each line read from the file, a length */
for (n = 0; n < storage->line_count; n++) {
line_len[n] = dt_read_line(storage->line[n],
DTOP_MEM_LINE, data,
DTOP_MEM_SIZE, sum);
if (n < (storage->line_count - 1))
sum += (line_len[n] + 1);
}
/* Stores dp names in dictionary */
for (i = 0; i < (storage->line_count); i++)
dt_parse_proc_same_line_key_and_val(storage->line[i],
line_len[i], i, &dict);
data_points = malloc
(storage->line_count * sizeof(struct dtop_data_point));
k = 0;
/* Creates a dtop_data_point struct for each dp found in the file */
for (i = 0; i < dict.max; i++) {
data_points[i].name = dict.key[i];
data_points[i].prefix = NULL;
data_points[i].type = DTOP_ULONG;
k++;
}
/* Calls dpg constructor, dpg will point to the dp struct */
construct_meminfo_file_dpg(data_points, storage);
free(line_len);
dt_free(&data);
return DTOP_POLL_OK;
}
示例5: dt_proc_hash_destroy
void
dt_proc_hash_destroy(dtrace_hdl_t *dtp)
{
dt_proc_hash_t *dph = dtp->dt_procs;
dt_proc_t *dpr;
while ((dpr = dt_list_next(&dph->dph_lrulist)) != NULL)
dt_proc_destroy(dtp, dpr->dpr_proc);
dtp->dt_procs = NULL;
dt_free(dtp, dph);
}
示例6: dt_dof_reset
static int
dt_dof_reset(dtrace_hdl_t *dtp, dtrace_prog_t *pgp)
{
dt_dof_t *ddo = &dtp->dt_dof;
uint_t i, nx = dtp->dt_xlatorid;
assert(ddo->ddo_hdl == dtp);
ddo->ddo_pgp = pgp;
ddo->ddo_nsecs = 0;
ddo->ddo_strsec = DOF_SECIDX_NONE;
dt_free(dtp, ddo->ddo_xlimport);
dt_free(dtp, ddo->ddo_xlexport);
ddo->ddo_xlimport = dt_alloc(dtp, sizeof (dof_secidx_t) * nx);
ddo->ddo_xlexport = dt_alloc(dtp, sizeof (dof_secidx_t) * nx);
if (nx != 0 && (ddo->ddo_xlimport == NULL || ddo->ddo_xlexport == NULL))
return (-1); /* errno is set for us */
for (i = 0; i < nx; i++) {
ddo->ddo_xlimport[i] = DOF_SECIDX_NONE;
ddo->ddo_xlexport[i] = DOF_SECIDX_NONE;
}
dt_buf_reset(dtp, &ddo->ddo_secs);
dt_buf_reset(dtp, &ddo->ddo_strs);
dt_buf_reset(dtp, &ddo->ddo_ldata);
dt_buf_reset(dtp, &ddo->ddo_udata);
dt_buf_reset(dtp, &ddo->ddo_probes);
dt_buf_reset(dtp, &ddo->ddo_args);
dt_buf_reset(dtp, &ddo->ddo_offs);
dt_buf_reset(dtp, &ddo->ddo_enoffs);
dt_buf_reset(dtp, &ddo->ddo_rels);
dt_buf_reset(dtp, &ddo->ddo_xlms);
return (0);
}
示例7: dt_buf_claim
void *
dt_buf_claim(dtrace_hdl_t *dtp, dt_buf_t *bp)
{
void *buf = bp->dbu_buf;
if (bp->dbu_err != 0) {
dt_free(dtp, buf);
buf = NULL;
}
bp->dbu_buf = bp->dbu_ptr = NULL;
bp->dbu_len = 0;
return (buf);
}
示例8: dt_optimize
void dt_optimize(dt_t *dt)
{ dt_t *dtn;
if (dt)
{ for (; 1; dt = dtn)
{
dtn = dt->DTnext;
if (!dtn)
break;
switch (dt->dt)
{
case DT_azeros:
if (dtn->dt == DT_1byte && dtn->DTonebyte == 0)
{
dt->DTazeros += 1;
goto L1;
}
else if (dtn->dt == DT_azeros)
{
dt->DTazeros += dtn->DTazeros;
goto L1;
}
break;
case DT_1byte:
if (dt->DTonebyte == 0)
{
if (dtn->dt == DT_1byte && dtn->DTonebyte == 0)
{
dt->DTazeros = 2;
goto L1;
}
else if (dtn->dt == DT_azeros)
{
dt->DTazeros = 1 + dtn->DTazeros;
L1:
dt->dt = DT_azeros;
dt->DTnext = dtn->DTnext;
dtn->DTnext = NULL;
dt_free(dtn);
dtn = dt;
}
}
break;
}
}
}
}
示例9: dt_proc_error
/*PRINTFLIKE3*/
static struct ps_prochandle *
dt_proc_error(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *format, ...)
{
va_list ap;
va_start(ap, format);
dt_set_errmsg(dtp, NULL, NULL, NULL, 0, format, ap);
va_end(ap);
if (dpr->dpr_proc != NULL)
Prelease(dpr->dpr_proc, 0);
dt_free(dtp, dpr);
(void) dt_set_errno(dtp, EDT_COMPILER);
return (NULL);
}
示例10: dt_proc_bpdestroy
static void
dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts)
{
int state = Pstate(dpr->dpr_proc);
dt_bkpt_t *dbp, *nbp;
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = nbp) {
if (delbkpts && dbp->dbp_active &&
state != PS_LOST && state != PS_UNDEAD) {
(void) Pdelbkpt(dpr->dpr_proc,
dbp->dbp_addr, dbp->dbp_instr);
}
nbp = dt_list_next(dbp);
dt_list_delete(&dpr->dpr_bps, dbp);
dt_free(dpr->dpr_hdl, dbp);
}
}
示例11: dt_inttab_create
dt_inttab_t *
dt_inttab_create(dtrace_hdl_t *dtp)
{
uint_t len = _dtrace_intbuckets;
dt_inttab_t *ip;
assert((len & (len - 1)) == 0);
if ((ip = dt_zalloc(dtp, sizeof (dt_inttab_t))) == NULL ||
(ip->int_hash = dt_zalloc(dtp, sizeof (void *) * len)) == NULL) {
dt_free(dtp, ip);
return (NULL);
}
ip->int_hdl = dtp;
ip->int_hashlen = len;
return (ip);
}
示例12: dt_buf_write
void
dt_buf_write(dtrace_hdl_t *dtp, dt_buf_t *bp,
const void *buf, size_t len, size_t align)
{
size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf);
size_t adj = roundup(off, align) - off;
if (bp->dbu_err != 0) {
(void) dt_set_errno(dtp, bp->dbu_err);
return; /* write silently fails */
}
if (bp->dbu_ptr + adj + len > bp->dbu_buf + bp->dbu_len) {
size_t new_len = bp->dbu_len * 2;
uchar_t *new_buf;
uint_t r = 1;
while (bp->dbu_ptr + adj + len > bp->dbu_buf + new_len) {
new_len *= 2;
r++;
}
if ((new_buf = dt_zalloc(dtp, new_len)) == NULL) {
bp->dbu_err = dtrace_errno(dtp);
return;
}
bcopy(bp->dbu_buf, new_buf, off);
dt_free(dtp, bp->dbu_buf);
bp->dbu_buf = new_buf;
bp->dbu_ptr = new_buf + off;
bp->dbu_len = new_len;
bp->dbu_resizes += r;
}
bp->dbu_ptr += adj;
bcopy(buf, bp->dbu_ptr, len);
bp->dbu_ptr += len;
}
示例13: dt_opt_preallocate
/*ARGSUSED*/
static int
dt_opt_preallocate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
{
dtrace_optval_t size;
void *p;
if (arg == NULL || dt_optval_parse(arg, &size) != 0)
return (dt_set_errno(dtp, EDT_BADOPTVAL));
if (size > SIZE_MAX)
size = SIZE_MAX;
if ((p = dt_zalloc(dtp, size)) == NULL) {
do {
size /= 2;
} while ((p = dt_zalloc(dtp, size)) == NULL);
}
dt_free(dtp, p);
return (0);
}
示例14: while
/*************************
* Finish and return completed data structure.
*/
dt_t *DtBuilder::finish()
{
/* Merge all the 0s at the start of the list
* so we can later check for dtallzeros()
*/
if (head && head->dt == DT_azeros)
{
while (1)
{
dt_t *dtn = head->DTnext;
if (!(dtn && dtn->dt == DT_azeros))
break;
// combine head and dtn
head->DTazeros += dtn->DTazeros;
head->DTnext = dtn->DTnext;
dtn->DTnext = NULL;
dt_free(dtn);
}
}
return head;
}
示例15: dt_pq_init
/*
* Create a new priority queue.
*
* size is the maximum number of items that will be stored in the priority
* queue at one time.
*/
dt_pq_t *
dt_pq_init(dtrace_hdl_t *dtp, uint_t size, dt_pq_value_f value_cb, void *cb_arg)
{
dt_pq_t *p;
assert(size > 1);
if ((p = dt_zalloc(dtp, sizeof (dt_pq_t))) == NULL)
return (NULL);
p->dtpq_items = dt_zalloc(dtp, size * sizeof (p->dtpq_items[0]));
if (p->dtpq_items == NULL) {
dt_free(dtp, p);
return (NULL);
}
p->dtpq_hdl = dtp;
p->dtpq_size = size;
p->dtpq_last = 1;
p->dtpq_value = value_cb;
p->dtpq_arg = cb_arg;
return (p);
}