本文整理汇总了C++中SLfree函数的典型用法代码示例。如果您正苦于以下问题:C++ SLfree函数的具体用法?C++ SLfree怎么用?C++ SLfree使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SLfree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SLcurses_delwin
int SLcurses_delwin (SLcurses_Window_Type *w)
{
if (w == NULL) return 0;
if (w->lines != NULL)
{
SLcurses_Cell_Type **lines = w->lines;
if (w->is_subwin == 0)
{
unsigned int r, rmax;
rmax = w->nrows;
for (r = 0; r < rmax; r++)
{
SLfree ((char *)lines[r]);
}
}
SLfree ((char *)lines);
}
SLfree ((char *)w);
if (w == SLcurses_Stdscr)
SLcurses_Stdscr = NULL;
return 0;
}
示例2: posix_fdopen
static void posix_fdopen (SLFile_FD_Type *f, char *mode)
{
Stdio_MMT_List_Type *elem;
if (NULL == (elem = alloc_stdio_list_elem ()))
return;
if (-1 == _pSLstdio_fdopen (f->name, f->fd, mode))
{
SLfree ((char *)elem);
return;
}
if (NULL == (elem->stdio_mmt = SLang_pop_mmt (SLANG_FILE_PTR_TYPE)))
{
SLfree ((char *) elem);
return;
}
if (-1 == SLang_push_mmt (elem->stdio_mmt))
{
SLfree ((char *) elem);
return;
}
elem->next = f->stdio_mmt_list;
f->stdio_mmt_list = elem;
}
示例3: delete_assoc_array
static void delete_assoc_array (SLang_Assoc_Array_Type *a)
{
_pSLAssoc_Array_Element_Type *e, *emax;
#if SLANG_OPTIMIZE_FOR_SPEED
int is_scalar_type = a->is_scalar_type;
#endif
if (a == NULL) return;
e = a->elements;
if (e != NULL)
{
emax = e + a->table_len;
while (e < emax)
{
if ((e->key != NULL) && (e->key != Deleted_Key))
{
_pSLfree_hashed_string ((char *)e->key, strlen (e->key), e->hash);
#if SLANG_OPTIMIZE_FOR_SPEED
if ((is_scalar_type == 0) && (e->value.o_data_type != SLANG_INT_TYPE))
#endif
SLang_free_object (&e->value);
}
e++;
}
SLfree ((char *) a->elements);
}
if (a->flags & HAS_DEFAULT_VALUE)
SLang_free_object (&a->default_value);
SLfree ((char *) a);
}
示例4: SLrline_close
void SLrline_close (SLrline_Type *rli)
{
if (rli == NULL)
return;
if (rli->name != NULL)
{
char hookname[1024];
SLrline_Type *arli = Active_Rline_Info;
Active_Rline_Info = rli;
SLsnprintf (hookname, sizeof(hookname), "%s_rline_close_hook", rli->name);
if (0 == SLang_run_hooks (hookname, 0))
(void) SLang_run_hooks ("rline_close_hook", 1, rli->name);
Active_Rline_Info = arli;
SLang_free_slstring (rli->name);
}
free_history (rli->root);
free_history_item (rli->saved_line);
SLang_free_function (rli->list_completions_callback);
SLang_free_function (rli->completion_callback);
SLfree ((char *)rli->prompt);
SLfree ((char *)rli->buf);
SLfree ((char *)rli);
}
示例5: exec_what
static int exec_what (int what, int has_envp)
{
SLang_Array_Type *at_argv = NULL;
SLang_Array_Type *at_envp = NULL;
char **argv = NULL, **envp = NULL;
char *path = NULL;
int status = -1;
if (has_envp)
{
if (NULL == (envp = pop_argv (&at_envp)))
goto free_and_return;
}
if (NULL == (argv = pop_argv (&at_argv)))
goto free_and_return;
if (-1 == SLang_pop_slstring (&path))
goto free_and_return;
status = call_what (what, path, argv, envp);
free_and_return:
if (path != NULL) SLang_free_slstring (path);
if (argv != NULL) SLfree ((char *)argv);
if (at_argv != NULL) SLang_free_array (at_argv);
if (envp != NULL) SLfree ((char *)envp);
if (at_envp != NULL) SLang_free_array (at_envp);
return status;
}
示例6: example_3
static int example_3 (void)
{
SLrline_Type *rl;
unsigned int width = 80;
if ((-1 == SLang_init_all ())
|| (-1 == SLang_init_array_extra ())
|| (-1 == SLang_init_import ()))
return -1;
(void) SLpath_set_load_path ("../slsh/lib");
if (-1 == SLrline_init ("demo/rline", NULL, NULL))
return -1;
issue_instructions ();
SLang_init_tty (-1, 0, 1);
SLang_set_abort_signal (NULL);
rl = SLrline_open2 ("rline", width, SL_RLINE_BLINK_MATCH);
if (rl == NULL)
return -1;
while (1)
{
char *line;
unsigned int len;
line = SLrline_read_line (rl, "prompt>", &len);
if (line == NULL)
{
int err = SLang_get_error ();
if (err == SL_UserBreak_Error)
{
(void) fprintf (stderr, "*Interrupted*\n");
SLang_set_error (0);
SLKeyBoard_Quit = 0;
continue;
}
if (err == 0)
break; /* EOF */
fprintf (stderr, "Error Occurred: %s\n", SLerr_strerror (err));
break;
}
if (0 == strcmp (line, "quit"))
{
SLfree (line);
break;
}
(void) fprintf (stdout, "\nRead %d bytes: %s\n", strlen(line), line);
if (-1 == SLrline_save_line (rl))
break;
SLfree (line);
}
SLrline_close (rl);
SLang_reset_tty ();
return 0;
}
示例7: example_1
static int example_1 (void)
{
SLrline_Type *rl;
unsigned int width = 80;
issue_instructions ();
SLang_init_tty (-1, 0, 1);
rl = SLrline_open (width, SL_RLINE_BLINK_MATCH);
while (1)
{
char *line;
unsigned int len;
line = SLrline_read_line (rl, "prompt>", &len);
if (line == NULL)
break;
if (0 == strcmp (line, "quit"))
{
SLfree (line);
break;
}
(void) fprintf (stdout, "\nRead %d bytes: %s\n", strlen(line), line);
SLfree (line);
}
SLrline_close (rl);
SLang_reset_tty ();
return 0;
}
示例8: SLbstring_free
void SLbstring_free (SLang_BString_Type *b)
{
if (b == NULL)
return;
if (b->num_refs > 1)
{
b->num_refs -= 1;
return;
}
switch (b->ptr_type)
{
case 0:
case IS_NOT_TO_BE_FREED:
default:
break;
case IS_SLSTRING:
SLang_free_slstring ((char *)b->v.ptr);
break;
case IS_MALLOCED:
SLfree ((char *)b->v.ptr);
break;
}
SLfree ((char *) b);
}
示例9: free_host_addr_info
static void free_host_addr_info (Host_Addr_Info_Type *hinfo)
{
if (hinfo == NULL)
return;
if (hinfo->h_addr_list != NULL)
SLfree ((char *)hinfo->h_addr_list);
SLfree ((char *) hinfo);
}
示例10: SLwchar_free_lut
void SLwchar_free_lut (SLwchar_Lut_Type *r)
{
if (r == NULL)
return;
SLfree ((char *) r->chmin);
SLfree ((char *) r->chmax);
SLfree ((char *) r);
}
示例11: SLang_free_array
/* reverse index converter from John Davis */
static SLang_Array_Type *convert_reverse_indices (SLindex_Type *r, SLindex_Type num_r, SLindex_Type num_h)
{
SLang_Array_Type *new_r;
SLang_Array_Type **new_r_data;
SLindex_Type i, *lens;
if (NULL == (new_r = SLang_create_array (SLANG_ARRAY_TYPE, 0, NULL, &num_h, 1)))
return NULL;
if (NULL == (lens = (SLindex_Type *)SLmalloc (num_h * sizeof (SLindex_Type))))
{
SLang_free_array (new_r);
return NULL;
}
memset ((char *)lens, 0, num_h*sizeof(SLindex_Type));
for (i = 0; i < num_r; i++)
{
SLindex_Type r_i = r[i];
if (r_i >= 0)
lens[r_i]++;
}
new_r_data = (SLang_Array_Type **) new_r->data;
for (i = 0; i < num_h; i++)
{
if (NULL == (new_r_data[i] = SLang_create_array (SLANG_ARRAY_INDEX_TYPE, 0, NULL, &lens[i], 1)))
goto return_error;
lens[i] = 0;
}
for (i = 0; i < num_r; i++)
{
SLang_Array_Type *at;
SLindex_Type r_i = r[i];
if (r_i < 0)
continue;
at = new_r_data[r_i];
((SLindex_Type *)at->data)[lens[r_i]] = i;
lens[r_i]++;
}
SLfree ((char *)lens);
return new_r;
return_error:
SLfree ((char *) lens);
SLang_free_array (new_r);
return NULL;
}
示例12: arith_bin_op
static int arith_bin_op (int op,
SLtype a_type, VOID_STAR ap, unsigned int na,
SLtype b_type, VOID_STAR bp, unsigned int nb,
VOID_STAR cp)
{
Bin_Fun_Type binfun;
int c_indx;
SLtype c_type;
if ((a_type == b_type)
&& ((a_type == SLANG_CHAR_TYPE) || (a_type == SLANG_UCHAR_TYPE)))
{
switch (op)
{
case SLANG_EQ:
case SLANG_NE:
case SLANG_AND:
case SLANG_OR:
return char_char_arith_bin_op (op, a_type, ap, na, b_type, bp, nb, cp);
}
}
c_type = promote_to_common_type (a_type, b_type);
c_indx = TYPE_TO_TABLE_INDEX(c_type);
binfun = Bin_Fun_Map[c_indx];
if ((c_type != a_type) || (c_type != b_type))
{
int ret;
int a_indx = TYPE_TO_TABLE_INDEX(a_type);
int b_indx = TYPE_TO_TABLE_INDEX(b_type);
Convert_Fun_Type af = Binary_Matrix[a_indx][c_indx].convert_function;
Convert_Fun_Type bf = Binary_Matrix[b_indx][c_indx].convert_function;
if ((af != NULL)
&& (NULL == (ap = (VOID_STAR) (*af) (ap, na))))
return -1;
if ((bf != NULL)
&& (NULL == (bp = (VOID_STAR) (*bf) (bp, nb))))
{
if (af != NULL) SLfree ((char *) ap);
return -1;
}
ret = (*binfun) (op, a_type, ap, na, b_type, bp, nb, cp);
if (af != NULL) SLfree ((char *) ap);
if (bf != NULL) SLfree ((char *) bp);
return ret;
}
return (*binfun) (op, a_type, ap, na, b_type, bp, nb, cp);
}
示例13: reset_smg
static void reset_smg (void)
{
unsigned int i;
if (Smg_Inited == 0)
return;
for (i = 0; i < Screen_Rows; i++)
{
SLfree ((char *)SL_Screen[i].old);
SLfree ((char *)SL_Screen[i].neew);
SL_Screen[i].old = SL_Screen[i].neew = NULL;
}
This_Alt_Char = This_Color = 0;
Smg_Inited = 0;
}
示例14: push_values_array
static int push_values_array (Values_Array_Type *av, int allow_empty_array)
{
SLang_Array_Type *at;
char **new_values;
if (av->num == 0)
{
if (allow_empty_array == 0)
return SLang_push_null ();
SLfree ((char *) av->values);
av->values = NULL;
}
else
{
if (NULL == (new_values = (char **)SLrealloc ((char *)av->values, av->num*sizeof(char *))))
return -1;
av->values = new_values;
}
av->num_allocated = av->num;
at = SLang_create_array (SLANG_STRING_TYPE, 0, av->values, &av->num, 1);
if (at == NULL)
return -1;
av->num_allocated = 0;
av->num = 0;
av->values = NULL;
return SLang_push_array (at, 1);
}
示例15: input_new_helptopic
int input_new_helptopic(struct dsc$descriptor_s *newtopic, /*{{{*/
struct dsc$descriptor_s *prompt,
unsigned int *len_newtopic)
{
char *newtop, prompt_buf[256];
int dofree;
strncpy(prompt_buf,prompt->dsc$a_pointer,prompt->dsc$w_length);
prompt_buf[prompt->dsc$w_length] = 0;
newtop = "";
dofree = 0;
if ((SLang_run_hooks("vms_help_newtopic", 1, prompt_buf + 2) > 0)
&& (0 == SLpop_string (&newtop)))
dofree = 1;
strcpy (newtopic->dsc$a_pointer, newtop);
*len_newtopic = newtopic->dsc$w_length = strlen (newtop);
newtopic->dsc$b_dtype = DSC$K_DTYPE_T;
newtopic->dsc$b_class = DSC$K_CLASS_S;
if (dofree) SLfree(newtop);
return(1); /* should add codes that LIB$GET_INPUT can return */
}