Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
67531c42
Commit
67531c42
authored
26 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Portability fix for old SunOS releases: realloc(NULL, ...)
doesn't work there.
parent
79fcde48
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/libpq/fe-exec.c
+12
-6
12 additions, 6 deletions
src/interfaces/libpq/fe-exec.c
with
12 additions
and
6 deletions
src/interfaces/libpq/fe-exec.c
+
12
−
6
View file @
67531c42
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.7
0
1998/11/
18 00:47:28
tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.7
1
1998/11/
29 01:53:54
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -343,17 +343,23 @@ addTuple(PGresult *res, PGresAttValue *tup)
...
@@ -343,17 +343,23 @@ addTuple(PGresult *res, PGresAttValue *tup)
*
*
* We can use realloc because shallow copying of the structure is
* We can use realloc because shallow copying of the structure is
* okay. Note that the first time through, res->tuples is NULL.
* okay. Note that the first time through, res->tuples is NULL.
* realloc is supposed to do the right thing in that case. Also,
* While ANSI says that realloc() should act like malloc() in that
* on failure realloc is supposed to return NULL without damaging
* case, some old C libraries (like SunOS 4.1.x) coredump instead.
* On failure realloc is supposed to return NULL without damaging
* the existing allocation.
* the existing allocation.
* Note that the positions beyond res->ntups are garbage, not
* Note that the positions beyond res->ntups are garbage, not
* necessarily NULL.
* necessarily NULL.
*/
*/
int
newSize
=
(
res
->
tupArrSize
>
0
)
?
res
->
tupArrSize
*
2
:
128
;
int
newSize
=
(
res
->
tupArrSize
>
0
)
?
res
->
tupArrSize
*
2
:
128
;
PGresAttValue
**
newTuples
=
(
PGresAttValue
**
)
PGresAttValue
**
newTuples
;
if
(
res
->
tuples
==
NULL
)
newTuples
=
(
PGresAttValue
**
)
malloc
(
newSize
*
sizeof
(
PGresAttValue
*
));
else
newTuples
=
(
PGresAttValue
**
)
realloc
(
res
->
tuples
,
newSize
*
sizeof
(
PGresAttValue
*
));
realloc
(
res
->
tuples
,
newSize
*
sizeof
(
PGresAttValue
*
));
if
(
!
newTuples
)
if
(
!
newTuples
)
return
FALSE
;
/* realloc failed */
return
FALSE
;
/*
malloc or
realloc failed */
res
->
tupArrSize
=
newSize
;
res
->
tupArrSize
=
newSize
;
res
->
tuples
=
newTuples
;
res
->
tuples
=
newTuples
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment