--- a/src/database.c
+++ b/src/database.c
@@ -10,6 +10,7 @@
#include <gdbm.h>
#include <database.h>
+#include "common.h"
char *db_insert (char *file_name, char *name, char *msg, int mode)
{
@@ -66,7 +67,7 @@
GDBM_FILE dbf;
datum content;
datum key;
- static char msg[513] = { 0 };
+ static char msg[DEFAULT_BUF_SIZE] = { 0 };
if ((dbf = gdbm_open (file_name, 512, GDBM_READER, 0, 0)) == NULL)
return "db_lookup error";
@@ -76,10 +77,10 @@
content = gdbm_fetch (dbf, key);
if (content.dptr != NULL) {
- snprintf (msg, 512, "%s", content.dptr);
+ snprintf (msg, sizeof (msg), "%s", content.dptr);
free (content.dptr);
} else
- snprintf (msg, 512, "I haven't heard anything about %s.", entry);
+ snprintf (msg, sizeof (msg), "I haven't heard anything about %s.", entry);
gdbm_close (dbf);
return msg;
@@ -106,7 +107,7 @@
}
gdbm_close (dbf);
- snprintf (msg, 80, "I am holding %d %s in my database.", count, (count > 0) ? "rows" : "row");
+ snprintf (msg, sizeof (msg), "I am holding %d %s in my database.", count, (count > 0) ? "rows" : "row");
return msg;
}
@@ -136,7 +137,7 @@
}
gdbm_close (dbf);
- snprintf (msg, 80, "I am holding %d %s in my database.", count, (count > 0) ? "rows" : "row");
+ snprintf (msg, sizeof (msg), "I am holding %d %s in my database.", count, (count > 0) ? "rows" : "row");
return msg;
}
@@ -151,6 +152,6 @@
gdbm_reorganize (dbf);
gdbm_close (dbf);
- snprintf (msg, 80, "I reorganized the database.");
+ snprintf (msg, sizeof (msg), "I reorganized the database.");
return msg;
}