Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh/example readonly array parameter
- X-seq: zsh-workers 40524
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: zsh/example readonly array parameter
- Date: Fri, 10 Feb 2017 14:45:54 -0800
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=brasslantern-com.20150623.gappssmtp.com
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=pb7B3BojxDbWiBZmICQ8/kLBOo7RxXOBUxgfbgCr7Pg=; b=QQ4y1f7pge4uPTIjqr6GqNSYqI00swSMJjujISWERhoY2Yzxw6eK7pQeBCESfvD5fJ uGa7YsnJik3I5xxJmZjSyZxMeh2ptfB3FFwAUgqGhw57B0m0+wHXF7er4E2f9aAFSK1+ H6JUb+4M9GYW65u/7IhxVsX23B8ilK1l/fTLfVpSSUSSBRZuDznJ87pai933DM7AvBs2 0L44DhLo+kTlyoz6u35AeW96jbg7bu64n6Q2gC2azNSgFP5N/8DD2XxUmksJSnmlLGSP d0/mrff4Bq8sB4hmqwjc1aeo9PLDvI2sx1/ZHDrargPtL4a8aK3cemDO3K7k5UYOeymw JYOQ==
- In-reply-to: <1486764931.1626890.877319720.216613B2@webmail.messagingengine.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1486764931.1626890.877319720.216613B2@webmail.messagingengine.com>
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;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author