* Initialize the static structure to zeros, then
* apply all the default values.
*/
-static void init_resource(CONFIG *config, int type, RES_ITEM *items, int pass)
+static void init_resource0(CONFIG *config, int type, RES_ITEM *items, int pass)
{
int i;
int rindex = type - r_first;
}
/* Initialize a resouce with default values */
-bool init_resource(CONFIG *config, uint32_t type, void *res)
+bool init_resource(CONFIG *config, uint32_t type, void *res, int size)
{
RES_ITEM *items;
for (int i=0; resources[i].name; i++) {
if (!items) {
return false;
}
- init_resource(config, type, items, 1);
- memcpy(res, config->m_res_all, config->m_res_all_size);
+ init_resource0(config, type, items, 1);
+ memcpy(res, config->m_res_all, size);
return true;
}
}
}
state = p_resource;
res_type = resources[i].rcode;
- init_resource(this, res_type, items, pass);
+ init_resource0(this, res_type, items, pass);
break;
}
}
void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
void dump_each_resource(int type, void sendmsg(void *sock, const char *fmt, ...), void *sock);
void free_resource(RES *res, int type);
-bool init_resource(CONFIG *config, uint32_t type, void *res);
+bool init_resource(CONFIG *config, uint32_t type, void *res, int size);
bool save_resource(CONFIG *config, int type, RES_ITEM *item, int pass);
void unstrip_password(RES_TABLE *resources); /* Used for json stuff */
void strip_password(RES_TABLE *resources); /* Used for tray monitor */
void Conf::addRes(int type, const char *title)
{
RESMON *res = (RESMON *) malloc(sizeof(RESMON));
- init_resource(config, type, res);
+ init_resource(config, type, res, sizeof(RESMON));
res->type = type; // Not sure it's set by init_resource
res->new_resource = true; // We want to free this resource with the ConfTab
addResource(res, title);