Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
dc94d4ab
Commit
dc94d4ab
authored
Aug 08, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove xstrdup and friends who were only called once. Replace with
#ifdef calls.
parent
7dca975c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
56 deletions
+33
-56
src/port/dirmod.c
src/port/dirmod.c
+33
-56
No files found.
src/port/dirmod.c
View file @
dc94d4ab
...
...
@@ -10,7 +10,7 @@
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.1
5 2004/08/08 01:31:15
momjian Exp $
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.1
6 2004/08/08 03:51:20
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -224,74 +224,34 @@ pgsymlink(const char *oldpath, const char *newpath)
#endif
/* ----------------
* rmtree routines
* ----------------
*/
/* We undefined these above, so we redefine them */
/* We undefined this above, so we redefine it */
#if defined(WIN32) || defined(__CYGWIN__)
#define unlink(path) pgunlink(path)
#endif
#ifdef FRONTEND
static
void
*
xmalloc
(
size_t
size
)
{
void
*
result
;
result
=
malloc
(
size
);
if
(
!
result
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
1
);
}
return
result
;
}
static
char
*
xstrdup
(
const
char
*
s
)
{
char
*
result
;
result
=
strdup
(
s
);
if
(
!
result
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
1
);
}
return
result
;
}
#define xfree(n) free(n)
#else
/* on the backend, use palloc and friends */
#define xmalloc(n) palloc(n)
#define xstrdup(n) pstrdup(n)
#define xfree(n) pfree(n)
#endif
/*
* deallocate memory used for filenames
* rmt_cleanup
*
* deallocate memory used for filenames
*/
static
void
rmt_cleanup
(
char
**
filenames
)
{
char
**
fn
;
for
(
fn
=
filenames
;
*
fn
;
fn
++
)
xfree
(
*
fn
);
#ifdef FRONTEND
free
(
*
fn
);
free
(
filenames
);
#else
pfree
(
*
fn
);
xfree
(
filenames
);
pfree
(
filenames
);
#endif
}
/*
* rmtree
*
...
...
@@ -329,13 +289,30 @@ rmtree(char *path, bool rmtopdir)
rewinddir
(
dir
);
filenames
=
xmalloc
((
numnames
+
2
)
*
sizeof
(
char
*
));
#ifdef FRONTEND
if
((
filenames
=
malloc
((
numnames
+
2
)
*
sizeof
(
char
*
)))
==
NULL
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
1
);
}
#else
filenames
=
palloc
((
numnames
+
2
)
*
sizeof
(
char
*
));
#endif
numnames
=
0
;
while
((
file
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
file
->
d_name
,
"."
)
!=
0
&&
strcmp
(
file
->
d_name
,
".."
)
!=
0
)
filenames
[
numnames
++
]
=
xstrdup
(
file
->
d_name
);
#ifdef FRONTEND
if
((
filenames
[
numnames
++
]
=
strdup
(
file
->
d_name
))
==
NULL
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
1
);
}
#else
filenames
[
numnames
++
]
=
pstrdup
(
file
->
d_name
);
#endif
}
filenames
[
numnames
]
=
NULL
;
...
...
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