🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2609

volatile problem.

#2609
From: Joachim Huober
Date: Wed, 17 Apr 1996 15:44
51 lines
1834 bytes
Hi all,

Is volatile the oposite of const, and do the tricky things about const
also belong to volatile.
Exp:
	const char *foo;	/* foo points only to characters that
				 * will not be changed through foo 
				 */
	char *const foo;	/* foo is an unchanging pointer to a
				 * possibly changing char.
				 */
Does this correspond to:
	volatile char *foo;	/* foo points to characters that may
				 * be changed by other threads
				 */
	char *volatile foo;	/* foo is a pointer that may be changed
				 * by another thread.
				 */
My problem belongs to setjmp, longjmp.
I want to do a setjmp, then do some fancy mallocs. if a malloc fail,
I want to do a longjmp and I want to free everything allocated till then.

char *foo = NULL;
char *bar = NULL;
jmp_buf env;

if (setjmp(env) == 0) {
	foo = malloc(...);
	if (foo == NULL) {
		...
		longjmp(env,1);
	bar = malloc(...);
	if (bar == NULL) {
		...
		longjmp(env,1);
} else {
	if (foo != NULL)
		free(foo);
	if (bar != NULL)
		free(bar);
}
Where do I have to write the volatile qualifier to tell the compiler not 
to do anything clever.

Joachim
-- 
---------------------------------------------------------------------
Joachim Huober                                Phone: +49 731 502-6241
UDINE-Project,            URZ, University of Ulm, 89081 Ulm , Germany
E-mail: joachim.huober@rz.uni-ulm.de 
---------------------------------------------------------------------
Technical Details
Message-ID: <4l33ku$7ns@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: huober_j@spica.rz.uni-ulm.de (Joachim Huober)
Newsgroups: comp.lang.c.moderated
Subject: volatile problem.
Date: 17 Apr 1996 10:44:30 -0500
Organization: Universitaet Ulm
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4l33ku$7ns@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com