本文整理汇总了C++中zsfree函数的典型用法代码示例。如果您正苦于以下问题:C++ zsfree函数的具体用法?C++ zsfree怎么用?C++ zsfree使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zsfree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printshfuncnode
static void
printshfuncnode(HashNode hn, int printflags)
{
Shfunc f = (Shfunc) hn;
char *t = 0;
if ((printflags & PRINT_NAMEONLY) ||
((printflags & PRINT_WHENCE_SIMPLE) &&
!(printflags & PRINT_WHENCE_FUNCDEF))) {
zputs(f->node.nam, stdout);
putchar('\n');
return;
}
if ((printflags & (PRINT_WHENCE_VERBOSE|PRINT_WHENCE_WORD)) &&
!(printflags & PRINT_WHENCE_FUNCDEF)) {
nicezputs(f->node.nam, stdout);
printf((printflags & PRINT_WHENCE_WORD) ? ": function\n" :
" is a shell function\n");
return;
}
quotedzputs(f->node.nam, stdout);
if (f->funcdef || f->node.flags & PM_UNDEFINED) {
printf(" () {\n\t");
if (f->node.flags & PM_UNDEFINED)
printf("%c undefined\n\t", hashchar);
else
t = getpermtext(f->funcdef, NULL, 1);
if (f->node.flags & PM_TAGGED)
printf("%c traced\n\t", hashchar);
if (!t) {
char *fopt = "Utkz";
int flgs[] = {
PM_UNALIASED, PM_TAGGED, PM_KSHSTORED, PM_ZSHSTORED, 0
};
int fl;;
zputs("builtin autoload -X", stdout);
for (fl=0;fopt[fl];fl++)
if (f->node.flags & flgs[fl]) putchar(fopt[fl]);
} else {
zputs(t, stdout);
zsfree(t);
if (f->funcdef->flags & EF_RUN) {
printf("\n\t");
quotedzputs(f->node.nam, stdout);
printf(" \"[email protected]\"");
}
}
printf("\n}\n");
} else {
printf(" () { }\n");
}
}
示例2: checksched
static void
checksched(void)
{
time_t t;
struct schedcmd *sch;
if(!schedcmds)
return;
t = time(NULL);
/*
* List is ordered, so we only need to consider the
* head element.
*/
while (schedcmds && schedcmds->time <= t) {
/*
* Remove the entry to be executed from the list
* before execution: this makes quite sure that
* the entry hasn't been monkeyed with when we
* free it.
*/
sch = schedcmds;
schedcmds = sch->next;
/*
* Delete from the timed function list now in case
* the called code reschedules.
*/
scheddeltimed();
if ((sch->flags & SCHEDFLAG_TRASH_ZLE) && zleactive)
zleentry(ZLE_CMD_TRASH);
execstring(sch->cmd, 0, 0, "sched");
zsfree(sch->cmd);
zfree(sch, sizeof(struct schedcmd));
/*
* Fix time for future events.
* I had this outside the loop, for a little extra efficiency.
* However, it then occurred to me that having the list of
* forthcoming entries up to date could be regarded as
* a feature, and the inefficiency is negligible.
*
* Careful in case the code we called has already set
* up a timed event; if it has, that'll be up to date since
* we haven't changed the list here.
*/
if (schedcmds && !schedcmdtimed) {
/*
* We've already delete the function from the list.
*/
DPUTS(timedfns && firstnode(timedfns),
"BUG: already timed fn (1)");
schedaddtimed(schedcmds->time);
}
}
}
示例3: set_buffer
static void
set_buffer(UNUSED(Param pm), char *x)
{
if(x) {
setline(x, 0);
zsfree(x);
} else
zlecs = zlell = 0;
fixsuffix();
menucmp = 0;
}
示例4: freepfuncs
static void
freepfuncs(Pfunc f)
{
Pfunc n;
for (; f; f = n) {
n = f->next;
zsfree(f->name);
zfree(f, sizeof(*f));
}
}
示例5: ignore_suffix
mod_export void
ignore_suffix(int l)
{
if (l) {
char *tmp, sav;
int sl = strlen(compsuffix);
if ((l = sl - l) < 0)
l = 0;
tmp = tricat(compsuffix + l, compisuffix, "");
zsfree(compisuffix);
compisuffix = tmp;
sav = compsuffix[l];
compsuffix[l] = '\0';
tmp = ztrdup(compsuffix);
compsuffix[l] = sav;
zsfree(compsuffix);
compsuffix = tmp;
}
}
示例6: makesuffixstr
mod_export void
makesuffixstr(char *f, char *s, int n)
{
if (f) {
zsfree(suffixfunc);
suffixfunc = ztrdup(f);
suffixfunclen = n;
} else if (s) {
int inv, i, z = 0;
ZLE_STRING_T ws, lasts, wptr;
if (*s == '^' || *s == '!') {
inv = 1;
s++;
} else
inv = 0;
s = getkeystring(s, &i, GETKEYS_SUFFIX, &z);
s = metafy(s, i, META_USEHEAP);
ws = stringaszleline(s, 0, &i, NULL, NULL);
/* Remove suffix on uninsertable characters if \- was given *
* and the character class wasn't negated -- or vice versa. */
suffixnoinsrem = z ^ inv;
suffixlen = n;
lasts = wptr = ws;
while (i) {
if (i >= 3 && wptr[1] == ZWC('-')) {
ZLE_CHAR_T str[2];
if (wptr > lasts)
addsuffix(inv ? SUFTYP_NEGSTR : SUFTYP_POSSTR, 0,
lasts, wptr - lasts, n);
str[0] = *wptr;
str[1] = wptr[2];
addsuffix(inv ? SUFTYP_NEGRNG : SUFTYP_POSRNG, 0,
str, 2, n);
wptr += 3;
i -= 3;
lasts = wptr;
} else {
wptr++;
i--;
}
}
if (wptr > lasts)
addsuffix(inv ? SUFTYP_NEGSTR : SUFTYP_POSSTR, 0,
lasts, wptr - lasts, n);
free(ws);
} else
makesuffix(n);
}
示例7: ignore_prefix
mod_export void
ignore_prefix(int l)
{
if (l) {
char *tmp, sav;
int pl = strlen(compprefix);
if (l > pl)
l = pl;
sav = compprefix[l];
compprefix[l] = '\0';
tmp = tricat(compiprefix, compprefix, "");
zsfree(compiprefix);
compiprefix = tmp;
compprefix[l] = sav;
tmp = ztrdup(compprefix + l);
zsfree(compprefix);
compprefix = tmp;
}
}
示例8: freeshfuncnode
static void
freeshfuncnode(HashNode hn)
{
Shfunc shf = (Shfunc) hn;
zsfree(shf->node.nam);
if (shf->funcdef)
freeeprog(shf->funcdef);
if (shf->redir)
freeeprog(shf->redir);
zsfree(shf->filename);
if (shf->sticky) {
if (shf->sticky->n_on_opts)
zfree(shf->sticky->on_opts,
shf->sticky->n_on_opts * sizeof(*shf->sticky->on_opts));
if (shf->sticky->n_off_opts)
zfree(shf->sticky->off_opts,
shf->sticky->n_off_opts * sizeof(*shf->sticky->off_opts));
zfree(shf->sticky, sizeof(*shf->sticky));
}
zfree(shf, sizeof(struct shfunc));
}
示例9: addsuffixstring
mod_export void
addsuffixstring(int tp, int flags, char *chars, int lensuf)
{
int slen, alloclen;
ZLE_STRING_T suffixstr;
/* string needs to be writable... I've been regretting this for years.. */
chars = ztrdup(chars);
suffixstr = stringaszleline(chars, 0, &slen, &alloclen, NULL);
addsuffix(tp, flags, suffixstr, slen, lensuf);
zfree(suffixstr, alloclen);
zsfree(chars);
}
示例10: domove
static int
domove(char *nam, MoveFunc movefn, char *p, char *q, int flags)
{
struct stat st;
char *pbuf, *qbuf;
pbuf = ztrdup(unmeta(p));
qbuf = unmeta(q);
if(flags & MV_NODIRS) {
errno = EISDIR;
if(lstat(pbuf, &st) || S_ISDIR(st.st_mode)) {
zwarnnam(nam, "%s: %e", p, errno);
zsfree(pbuf);
return 1;
}
}
if(!lstat(qbuf, &st)) {
int doit = flags & MV_FORCE;
if(S_ISDIR(st.st_mode)) {
zwarnnam(nam, "%s: cannot overwrite directory", q);
zsfree(pbuf);
return 1;
} else if(flags & MV_INTERACTIVE) {
nicezputs(nam, stderr);
fputs(": replace `", stderr);
nicezputs(q, stderr);
fputs("'? ", stderr);
fflush(stderr);
if(!ask()) {
zsfree(pbuf);
return 0;
}
doit = 1;
} else if((flags & MV_ASKNW) &&
!S_ISLNK(st.st_mode) &&
access(qbuf, W_OK)) {
nicezputs(nam, stderr);
fputs(": replace `", stderr);
nicezputs(q, stderr);
fprintf(stderr, "', overriding mode %04o? ",
mode_to_octal(st.st_mode));
fflush(stderr);
if(!ask()) {
zsfree(pbuf);
return 0;
}
doit = 1;
}
if(doit && !(flags & MV_ATOMIC))
unlink(qbuf);
}
if(movefn(pbuf, qbuf)) {
zwarnnam(nam, "%s: %e", p, errno);
zsfree(pbuf);
return 1;
}
zsfree(pbuf);
return 0;
}
示例11: freecmlist
mod_export void
freecmlist(Cmlist l)
{
Cmlist n;
while (l) {
n = l->next;
freecmatcher(l->matcher);
zsfree(l->str);
zfree(l, sizeof(struct cmlist));
l = n;
}
}
示例12: cleanup_
int
cleanup_(Module m)
{
struct schedcmd *sch, *schn;
if (schedcmds)
scheddeltimed();
for (sch = schedcmds; sch; sch = schn) {
schn = sch->next;
zsfree(sch->cmd);
zfree(sch, sizeof(*sch));
}
delprepromptfn(&checksched);
return setfeatureenables(m, &module_features, NULL);
}
示例13: scanfindfunc
static void
scanfindfunc(char *seq, Thingy func, UNUSED(char *str), void *magic)
{
struct findfunc *ff = magic;
if(func != ff->func)
return;
if (!ff->found++)
ff->msg = appstr(ff->msg, " is on");
if(ff->found <= MAXFOUND) {
char *b = bindztrdup(seq);
ff->msg = appstr(ff->msg, " ");
ff->msg = appstr(ff->msg, b);
zsfree(b);
}
}
示例14: whereis
int
whereis(UNUSED(char **args))
{
struct findfunc ff;
if (!(ff.func = executenamedcommand("Where is: ")))
return 1;
ff.found = 0;
ff.msg = nicedup(ff.func->nam, 0);
scankeymap(curkeymap, 1, scanfindfunc, &ff);
if (!ff.found)
ff.msg = appstr(ff.msg, " is not bound to any key");
else if(ff.found > MAXFOUND)
ff.msg = appstr(ff.msg, " et al");
showmsg(ff.msg);
zsfree(ff.msg);
return 0;
}
示例15: set_rbuffer
static void
set_rbuffer(UNUSED(Param pm), char *x)
{
ZLE_STRING_T y;
int len;
if (x && *x != ZWC('\0'))
y = stringaszleline(x, 0, &len, NULL, NULL);
else
y = ZWS(""), len = 0;
sizeline(zlell = zlecs + len);
ZS_memcpy(zleline + zlecs, y, len);
zsfree(x);
if (len)
free(y);
fixsuffix();
menucmp = 0;
}