summaryrefslogtreecommitdiff
path: root/storage/connect/plgdbutl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect/plgdbutl.cpp')
-rw-r--r--storage/connect/plgdbutl.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index d5429e8a344..32f6d6f8366 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -294,8 +294,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
#else // !XMSG
GetRcString(ids + crp->Ncol, cname, sizeof(cname));
#endif // !XMSG
- crp->Name = (PSZ)PlugSubAlloc(g, NULL, strlen(cname) + 1);
- strcpy(crp->Name, cname);
+ crp->Name = (PSZ)PlugDup(g, cname);
} else
crp->Name = NULL; // Will be set by caller
@@ -853,8 +852,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype)
htrc(" fp=%p\n", fp);
// fname may be in volatile memory such as stack
- fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(fname) + 1);
- strcpy((char*)fp->Fname, fname);
+ fp->Fname = PlugDup(g, fname);
fp->Count = 1;
fp->Type = TYPE_FB_FILE;
fp->File = fop;
@@ -1401,6 +1399,23 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
} // end of PlgDBSubAlloc
/***********************************************************************/
+/* Program for sub-allocating and copying a string in a storage area. */
+/***********************************************************************/
+char *PlgDBDup(PGLOBAL g, const char *str)
+ {
+ if (str) {
+ char *sm = (char*)PlgDBSubAlloc(g, NULL, strlen(str) + 1);
+
+ if (sm)
+ strcpy(sm, str);
+
+ return sm;
+ } else
+ return NULL;
+
+ } // end of PlgDBDup
+
+/***********************************************************************/
/* PUTOUT: Plug DB object typing routine. */
/***********************************************************************/
void PlugPutOut(PGLOBAL g, FILE *f, short t, void *v, uint n)