Changeset: eb74bf7185d0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eb74bf7185d0
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:
Merge with Dec2025 branch.
diffs (105 lines):
diff --git a/tools/merovingian/daemon/controlrunner.c
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -964,7 +964,7 @@ static void ctl_handle_client(
if (strcmp(q, "#defaults") == 0) {
/* send defaults to client */
- writePropsBuf(_mero_db_props, &pbuf);
+ pbuf = writePropsBuf(_mero_db_props);
send_list();
Mlevelfprintf(INFORMATION,
_mero_ctlout, "%s: served default property "
@@ -1000,7 +1000,7 @@ static void ctl_handle_client(
/* from here we'll always succeed, even if we
don't
* send anything */
readProps(props, stats->path);
- writePropsBuf(props, &pbuf);
+ pbuf = writePropsBuf(props);
send_list();
freeConfFile(props);
free(props);
diff --git a/tools/merovingian/utils/properties.c
b/tools/merovingian/utils/properties.c
--- a/tools/merovingian/utils/properties.c
+++ b/tools/merovingian/utils/properties.c
@@ -21,9 +21,9 @@
#include <pthread.h>
#include <ctype.h>
-#define MEROPROPFILEHEADER \
- "# DO NOT EDIT THIS FILE - use monetdb(1) and monetdbd(1) to set
properties\n" \
- "# This file is used by monetdbd\n\n"
+static const char MEROPROPFILEHEADER[] =
+ "# DO NOT EDIT THIS FILE - use monetdb(1) and monetdbd(1) to set
properties\n"
+ "# This file is used by monetdbd\n\n";
/* these are the properties used for starting an mserver */
static const confkeyval _internal_prop_keys[PROPLENGTH] = {
@@ -84,7 +84,7 @@ getDefaultProps(void)
* Returns 0 when the properties could be successfully written to the file.
*/
int
-writeProps(confkeyval *ckv, const char *path)
+writeProps(const confkeyval *ckv, const char *path)
{
char file[1024];
FILE *cnf;
@@ -139,32 +139,25 @@ appendProp(confkeyval *ckv, const char *
* buf. This function deals with the allocation of the buffer, hence
* the caller should free it.
*/
-void
-writePropsBuf(confkeyval *ckv, char **buf)
+char *
+writePropsBuf(const confkeyval *ckv)
{
- confkeyval *w;
- size_t len = sizeof(MEROPROPFILEHEADER);
- char *p;
+ size_t len = sizeof(MEROPROPFILEHEADER); /* includes terminating \0 */
- w = ckv;
- while (w->key != NULL) {
+ for (const confkeyval *w = ckv; w->key != NULL; w++) {
if (w->val != NULL)
len += strlen(w->key) + 1 + strlen(w->val) + 1;
- w++;
}
- p = *buf = malloc(sizeof(char) * len + 1);
- memcpy(p, MEROPROPFILEHEADER, sizeof(MEROPROPFILEHEADER));
- p += sizeof(MEROPROPFILEHEADER) - 1;
- w = ckv;
- while (w->key != NULL) {
- if (w->val != NULL) {
- int l = snprintf(p, len + 1, "%s=%s\n", w->key, w->val);
- p += l;
- len -= l;
- }
- w++;
+ char *buf = malloc(sizeof(char) * len);
+ if (buf == NULL)
+ return NULL;
+ char *p = stpcpy(buf, MEROPROPFILEHEADER);
+ for (const confkeyval *w = ckv; w->key != NULL; w++) {
+ if (w->val != NULL)
+ p = stpcpy(stpcpy(stpcpy(stpcpy(p, w->key), "="),
w->val), "\n");
}
+ return buf;
}
/**
diff --git a/tools/merovingian/utils/properties.h
b/tools/merovingian/utils/properties.h
--- a/tools/merovingian/utils/properties.h
+++ b/tools/merovingian/utils/properties.h
@@ -16,8 +16,8 @@
#define MEROPROPFILE ".merovingian_properties"
confkeyval *getDefaultProps(void);
-int writeProps(confkeyval *ckv, const char *path);
-void writePropsBuf(confkeyval *ckv, char **buf);
+int writeProps(const confkeyval *ckv, const char *path);
+char *writePropsBuf(const confkeyval *ckv);
int readProps(confkeyval *ckv, const char *path);
int readAllProps(confkeyval *ckv, const char *path);
void readPropsBuf(confkeyval *ckv, char *buf);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]