* zsh/example readonly array parameter
@ 2017-02-10 22:15 Sebastian Gniazdowski
2017-02-10 22:45 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2017-02-10 22:15 UTC (permalink / raw)
To: zsh-workers
Hello,
How to make int and array parameters (defined via paramdef structure)
read-only? The reason:
# zmodload zsh/example
The example module has now been set up.
23:14[/Users/sgniazdowski]2# example a b c
Options:
Arguments: a b c
Name: example
Integer Parameter: 42
String Parameter: example
Array Parameter: example array
# unset exarr
# example a b c
utils.c:3896: freearray() with zero argument
zsh: segmentation fault zsh-5.3.1-dev-0
--
Sebastian Gniazdowski
psprint2@fastmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: zsh/example readonly array parameter
2017-02-10 22:15 zsh/example readonly array parameter Sebastian Gniazdowski
@ 2017-02-10 22:45 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2017-02-10 22:45 UTC (permalink / raw)
To: zsh-workers
On Feb 10, 2:15pm, Sebastian Gniazdowski wrote:
}
} How to make int and array parameters (defined via paramdef structure)
} read-only?
To answer what was asked:
PARAMDEF("exarr", PM_ARRAY|PM_READONLY, &arrparam, NULL);
However ...
} # unset exarr
}
} # example a b c
} utils.c:3896: freearray() with zero argument
} zsh: segmentation fault zsh-5.3.1-dev-0
... this is just the example module being stupid.
diff --git a/Src/Modules/example.c b/Src/Modules/example.c
index 45ca2cf..c80c9e7 100644
--- a/Src/Modules/example.c
+++ b/Src/Modules/example.c
@@ -69,7 +69,8 @@ bin_example(char *nam, char **args, Options ops, UNUSED(int func))
intparam = i;
zsfree(strparam);
strparam = ztrdup(*oargs ? *oargs : "");
- freearray(arrparam);
+ if (arrparam)
+ freearray(arrparam);
arrparam = zarrdup(oargs);
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-10 22:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 22:15 zsh/example readonly array parameter Sebastian Gniazdowski
2017-02-10 22:45 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).