Skip to content

Commit

Permalink
Changed Makefile for syb15, revised code to avoid mem leaks on except…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
vimsh committed Mar 25, 2017
1 parent 5d3244f commit 4522e6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = db_conn
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v0.2.0-alpha
PROJECT_NUMBER = v0.2.1-alpha

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
12 changes: 6 additions & 6 deletions Makefile_syb15.0
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ CC = /opt/gcc/bin/g++
CFLAGS = -std=c++1y -Wall -Wno-unused -Wno-sequence-point -Wno-parentheses -c -ggdb3 -m64 -pthread -DSYB_LP64 -D_REENTRANT

# sybase libraries to include in the build
CTLIB = -lsybct64 # client library
CSLIB = -lsybcs64 # cs library
TCLIB = -lsybtcl64 # transport control layer
COMLIB = -lsybcomn64 # internal shared utility library
INTLLIB = -lsybintl64 # internationalization support library
CTLIB = -lsybct_r64 # client library
CSLIB = -lsybcs_r64 # cs library
TCLIB = -lsybtcl_r64 # transport control layer
COMLIB = -lsybcomn_r64 # internal shared utility library
INTLLIB = -lsybintl_r64 # internationalization support library
BLKLIB = -lsybblk_r64 # bulk copy routines
UNICLIB = -lsybunic64 # unicode library
BLKLIB = -lsybblk64 # bulk copy routines
SYSLIBS = -Wl,-Bdynamic -ldl -lpthread -lnsl -lm
LIBS = -Bstatic $(LIBPATH) $(CTLIB) $(CSLIB) $(TCLIB) $(COMLIB) $(INTLLIB) $(UNICLIB) $(SYSLIBS)

Expand Down
11 changes: 4 additions & 7 deletions sqlite_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,18 +807,15 @@ class statement : public dbi::istatement
cancel();
command = cmd;
command.erase(std::find_if(command.rbegin(), command.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), command.end());
size_t plen = 0U;
std::vector<sqlite3_stmt*> stmts;
sqlite3_stmt* stmt;
size_t plen = 0;
while (command.length() > 0 && plen != command.length())
{
command.erase(command.begin(), std::find_if(command.begin(), command.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
prepare(command, &stmt);
stmts.push_back(stmt);
sqlite_stmts.push_back(nullptr);
prepare(command, &sqlite_stmts[sqlite_stmts.size() - 1]);
plen = command.length();
command = tail;
}
sqlite_stmts = stmts;
return fetch();
}

Expand Down Expand Up @@ -1043,7 +1040,7 @@ class statement : public dbi::istatement
std::string command;
result_set rs;
struct tm stm;
};
}; // statement


dbi::istatement* connection::get_statement(dbi::iconnection& iconn)
Expand Down
21 changes: 13 additions & 8 deletions sybase_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace vgi { namespace dbconn { namespace dbd { namespace sybase {
static auto TRUE = CS_TRUE;
static auto FALSE = CS_FALSE;

using Locale = CS_LOCALE;
using Context = CS_CONTEXT;
using Connection = CS_CONNECTION;
using ServerMessage = CS_SERVERMSG;
Expand Down Expand Up @@ -985,6 +986,8 @@ class driver : public idriver
public:
~driver()
{
if (cslocale != nullptr && cscontext != nullptr)
cs_loc_drop(cscontext, cslocale);
destroy(cscontext);
}

Expand Down Expand Up @@ -1210,6 +1213,7 @@ class driver : public idriver

void allocate(Context*& cs_context, CS_INT version)
{
destroy(cs_context);
if (CS_SUCCEED != cs_ctx_alloc(version, &cs_context))
throw std::runtime_error(std::string(__FUNCTION__).append(": Failed to allocate context struct"));
if (CS_SUCCEED != ct_init(cs_context, version))
Expand All @@ -1221,12 +1225,13 @@ class driver : public idriver

void destroy(Context*& cs_context)
{
if (cslocale != nullptr)
cs_loc_drop(cscontext, cslocale);
if (CS_SUCCEED != ct_exit(cs_context, CS_UNUSED))
ct_exit(cs_context, CS_FORCE_EXIT);
cs_ctx_drop(cs_context);
cs_context = nullptr;
if (cs_context != nullptr)
{
if (CS_SUCCEED != ct_exit(cs_context, CS_UNUSED))
ct_exit(cs_context, CS_FORCE_EXIT);
cs_ctx_drop(cs_context);
cs_context = nullptr;
}
}

CS_INT version()
Expand Down Expand Up @@ -1275,10 +1280,10 @@ class driver : public idriver
#endif
}
}
destroy(cs_context);
}
catch (...)
{ }
destroy(cs_context);
return version;
}

Expand All @@ -1294,7 +1299,7 @@ class driver : public idriver
"CS_SV_FATAL"
}};

CS_LOCALE* cslocale = nullptr;
Locale* cslocale = nullptr;
Context* cscontext = nullptr;
CS_INT dbg_flag = 0;
std::string protofile;
Expand Down

0 comments on commit 4522e6d

Please sign in to comment.