summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-03 19:21:56 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-03 19:21:56 +0100
commit61de706cf43afba9d637ef099644c58d0de492c9 (patch)
treed88a12884f2c9df403ed8ef630c4a515c71851e5 /lib/Utils
parent51f279ca689ea79a873d1f80b000fd3f163b3087 (diff)
downloadabrt-61de706cf43afba9d637ef099644c58d0de492c9.tar.gz
abrt-61de706cf43afba9d637ef099644c58d0de492c9.tar.xz
abrt-61de706cf43afba9d637ef099644c58d0de492c9.zip
SQLite3: string& -> char*, -8k in code size
Run tested Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/Database.h18
-rw-r--r--lib/Utils/xfuncs.cpp45
2 files changed, 28 insertions, 35 deletions
diff --git a/lib/Utils/Database.h b/lib/Utils/Database.h
index c7a95ba..1691f1c 100644
--- a/lib/Utils/Database.h
+++ b/lib/Utils/Database.h
@@ -84,8 +84,8 @@ class CDatabase : public CPlugin
* @param pUUID A lodal UUID of a crash.
* @param pUID An UID of an user.
*/
- virtual void DeleteRow(const std::string& pUUID,
- const std::string& pUID) = 0;
+ virtual void DeleteRow(const char *pUUID,
+ const char *pUID) = 0;
virtual void DeleteRows_by_dir(const char *dump_dir) = 0;
/**
* A method, which sets that particular row was reported.
@@ -94,9 +94,9 @@ class CDatabase : public CPlugin
* @param pMessage A text explanation of reported problem
* (where it is stored etc)...
*/
- virtual void SetReported(const std::string& pUUID,
- const std::string& pUID,
- const std::string& pMessage) = 0;
+ virtual void SetReported(const char *pUUID,
+ const char *pUID,
+ const char *pMessage) = 0;
/**
* A method, which gets all rows which belongs to particular user.
* If the user is root, then all rows are returned. If there are no
@@ -104,7 +104,7 @@ class CDatabase : public CPlugin
* @param pUID An UID of an user.
* @return A vector of matched rows.
*/
- virtual vector_database_rows_t GetUIDData(const std::string& pUID) = 0;
+ virtual vector_database_rows_t GetUIDData(const char *pUID) = 0;
/**
* A method, which returns one row accordind to UUID of a crash and
* UID of an user. If there are no row, empty row is returned.
@@ -112,8 +112,8 @@ class CDatabase : public CPlugin
* @param pUID An UID of an user.
* @return A matched row.
*/
- virtual database_row_t GetRow(const std::string& pUUID,
- const std::string& pUID) = 0;
+ virtual database_row_t GetRow(const char *pUUID,
+ const char *pUID) = 0;
};
-#endif /* DATABASE_H_ */
+#endif
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index 583171f..b1941f7 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -141,28 +141,22 @@ off_t xlseek(int fd, off_t offset, int whence)
return off;
}
-// Die with an error message if we can't malloc() enough space and do an
-// sprintf() into that space.
-char* xasprintf(const char *format, ...)
+char* xvasprintf(const char *format, va_list p)
{
- va_list p;
int r;
char *string_ptr;
#if 1
// GNU extension
- va_start(p, format);
r = vasprintf(&string_ptr, format, p);
- va_end(p);
#else
// Bloat for systems that haven't got the GNU extension.
- va_start(p, format);
+ va_list p2;
r = vsnprintf(NULL, 0, format, p);
- va_end(p);
+ va_copy(p2, p);
string_ptr = xmalloc(r+1);
- va_start(p, format);
- r = vsnprintf(string_ptr, r+1, format, p);
- va_end(p);
+ r = vsnprintf(string_ptr, r+1, format, p2);
+ va_end(p2);
#endif
if (r < 0)
@@ -170,30 +164,29 @@ char* xasprintf(const char *format, ...)
return string_ptr;
}
-std::string ssprintf(const char *format, ...)
+// Die with an error message if we can't malloc() enough space and do an
+// sprintf() into that space.
+char* xasprintf(const char *format, ...)
{
va_list p;
- int r;
char *string_ptr;
-#if 1
- // GNU extension
- va_start(p, format);
- r = vasprintf(&string_ptr, format, p);
- va_end(p);
-#else
- // Bloat for systems that haven't got the GNU extension.
va_start(p, format);
- r = vsnprintf(NULL, 0, format, p);
+ string_ptr = xvasprintf(format, p);
va_end(p);
- string_ptr = xmalloc(r+1);
+
+ return string_ptr;
+}
+
+std::string ssprintf(const char *format, ...)
+{
+ va_list p;
+ char *string_ptr;
+
va_start(p, format);
- r = vsnprintf(string_ptr, r+1, format, p);
+ string_ptr = xvasprintf(format, p);
va_end(p);
-#endif
- if (r < 0)
- die_out_of_memory();
std::string res = string_ptr;
free(string_ptr);
return res;