Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Jeffrey Lee
RISC_OSLib
Commits
0d56fc75
Commit
0d56fc75
authored
27 years ago
by
Kevin Bracey
Browse files
Options
Download
Email Patches
Plain Diff
Do MessageTrans_CloseFile on exit, for safety's sake.
parent
782f8778
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
rlib/c/msgs
rlib/c/msgs
+14
-3
No files found.
rlib/c/msgs
View file @
0d56fc75
...
...
@@ -36,6 +36,7 @@
* cannot be opened.
* 10-Dec-91 ECN Changed to use RISC_OSLibrary$Path again.
* 23-Mar-92 ECN Reverted to old messages lookup scheme.
* 16-Jun-97 KJB Close messages file on exit, for safety's sake.
*/
#include <stdlib.h>
...
...
@@ -57,6 +58,14 @@ typedef struct msgs_block {
static
msgs_block
main_msgs_block
;
static
msgs_block
default_msgs_block
;
static
void
__msgs_closefiles
(
void
)
{
if
(
main_msgs_block
.
lines
)
_swix
(
MessageTrans_CloseFile
,
_IN
(
0
),
&
main_msgs_block
.
cb
);
if
(
default_msgs_block
.
lines
)
_swix
(
MessageTrans_CloseFile
,
_IN
(
0
),
&
default_msgs_block
.
cb
);
}
static
void
__msgs_readfile
(
char
*
name
,
msgs_block
*
mb
)
{
char
*
data
;
...
...
@@ -71,10 +80,10 @@ static void __msgs_readfile(char *name, msgs_block *mb)
size
=
_swi
(
MessageTrans_FileInfo
,
_IN
(
1
)
|
_RETURN
(
2
),
name
);
data
=
malloc
(
size
);
if
(
!
data
)
{
wimpt_reporterror
((
os_error
*
)
_swix
(
MessageTrans_ErrorLookup
,
_IN
(
0
)
|
_IN
(
1
)
|
_IN
(
2
),
"
\0\0\0\0
NoMem"
,
0
,
0
),
0
);
wimpt_reporterror
((
os_error
*
)
_swix
(
MessageTrans_ErrorLookup
,
_IN
R
(
0
,
2
),
"
\0\0\0\0
NoMem"
,
0
,
0
),
0
);
exit
(
1
);
}
err
=
_swix
(
MessageTrans_OpenFile
,
_IN
(
0
)
|
_IN
(
1
)
|
_IN
(
2
),
&
mb
->
cb
,
name
,
data
);
err
=
_swix
(
MessageTrans_OpenFile
,
_IN
R
(
0
,
2
),
&
mb
->
cb
,
name
,
data
);
if
(
err
)
{
wimpt_reporterror
(
err
,
0
);
exit
(
1
);
...
...
@@ -90,7 +99,8 @@ static void __msgs_readfile(char *name, msgs_block *mb)
}
while
(
p
<
e
);
lines
=
malloc
(
n
*
4
);
if
(
!
lines
)
{
wimpt_reporterror
((
os_error
*
)
_swix
(
MessageTrans_ErrorLookup
,
_IN
(
0
)
|
_IN
(
1
)
|
_IN
(
2
),
"
\0\0\0\0
NoMem"
,
0
,
0
),
0
);
_swix
(
MessageTrans_CloseFile
,
_IN
(
0
),
&
mb
->
cb
);
wimpt_reporterror
((
os_error
*
)
_swix
(
MessageTrans_ErrorLookup
,
_INR
(
0
,
2
),
"
\0\0\0\0
NoMem"
,
0
,
0
),
0
);
exit
(
1
);
}
p
=
data
+
4
;
...
...
@@ -188,4 +198,5 @@ void msgs_init(void)
res_findname
(
"Messages"
,
name
);
__msgs_readfile
(
name
,
&
main_msgs_block
);
atexit
(
__msgs_closefiles
);
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment