Skip to content

Commit 48cc0e8

Browse files
committed
refac: hidestderr: use proc(var state) instead of proc(ref state)
- simpler - no need for complex ref concepts
1 parent f51e3b3 commit 48cc0e8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pnimrp.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type
2424
stationsDir: string
2525
version: string # Application version
2626

27-
var state = new StderrState
27+
var state: StderrState
2828

2929
const
3030
AppName = "Poor Man's Radio Player" # Name of the application

src/ui/hidestderr.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ template checkError(status: cint) =
4444
template cE(status: cint) =
4545
checkError(status)
4646

47-
proc initSuppressStderr*(state: ref StderrState) =
47+
proc initSuppressStderr*(state: var StderrState) =
4848
when win32: state.originalStderrFd = c_dup(c_fileno(stderr))
4949
else: state.originalStderrFd = c_dup(c_fileno(stderr))
5050

@@ -56,7 +56,7 @@ proc initSuppressStderr*(state: ref StderrState) =
5656
error("failed to suppress stderr")
5757
quit(QuitFailure)
5858

59-
proc restoreStderr*(state: ref StderrState) =
59+
proc restoreStderr*(state: var StderrState) =
6060
flushFile(stderr)
6161

6262
when win32:
@@ -79,7 +79,7 @@ proc restoreStderr*(state: ref StderrState) =
7979
else: cE c_dup2(c_fileno(stdout), c_fileno(stderr))
8080

8181
when isMainModule:
82-
var state = new StderrState
82+
var state: StderrState
8383
echo("this goes to stdout")
8484

8585
state.initSuppressStderr()

0 commit comments

Comments
 (0)