Rewrite virConfReadMem to take a null-terminated string.
All the callers were calling strlen on it anyway.
virConfPtr conf;
int ret;
- conf = virConfReadMem(filedata, strlen(filedata), 0);
+ conf = virConfReadString(filedata, 0);
if (!conf)
return -1;
virConfLoadConfig;
virConfNew;
virConfReadFile;
-virConfReadMem;
+virConfReadString;
virConfSetValue;
virConfTypeFromString;
virConfTypeToString;
goto cleanup;
if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XL)) {
- if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0)))
+ if (!(conf = virConfReadString(nativeConfig, 0)))
goto cleanup;
if (!(def = xenParseXL(conf,
cfg->caps,
driver->xmlopt)))
goto cleanup;
} else if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
- if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0)))
+ if (!(conf = virConfReadString(nativeConfig, 0)))
goto cleanup;
if (!(def = xenParseXM(conf,
virConfPtr properties = NULL;
virConfValuePtr value;
- if (!(properties = virConfReadMem(config, 0, VIR_CONF_FLAG_LXC_FORMAT)))
+ if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT)))
return NULL;
if (!(vmdef = virDomainDefNew()))
}
/**
- * virConfReadMem:
+ * virConfReadString:
* @memory: pointer to the content of the configuration file
- * @len: length in byte
* @flags: combination of virConfFlag(s)
*
- * Reads a configuration file loaded in memory. The string can be
- * zero terminated in which case @len can be 0
+ * Reads a configuration file loaded in memory. The string must be
+ * zero terminated.
*
* Returns a handle to lookup settings or NULL if it failed to
* parse the content, use virConfFree() to free the data.
*/
virConfPtr
-virConfReadMem(const char *memory, int len, unsigned int flags)
+virConfReadString(const char *memory, unsigned int flags)
{
- if ((memory == NULL) || (len < 0)) {
+ size_t len;
+
+ if (memory == NULL) {
virConfError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return NULL;
}
- if (len == 0)
- len = strlen(memory);
+ len = strlen(memory);
return virConfParse("memory conf", memory, len, flags);
}
virConfPtr virConfNew(void);
virConfPtr virConfReadFile(const char *filename, unsigned int flags);
-virConfPtr virConfReadMem(const char *memory,
- int len, unsigned int flags);
+virConfPtr virConfReadString(const char *memory,
+ unsigned int flags);
int virConfFree(virConfPtr conf);
void virConfFreeValue(virConfValuePtr val);
virConfValuePtr virConfGetValue(virConfPtr conf,
return NULL;
}
- conf = virConfReadMem(vmx, strlen(vmx), VIR_CONF_FLAG_VMX_FORMAT);
+ conf = virConfReadString(vmx, VIR_CONF_FLAG_VMX_FORMAT);
if (conf == NULL)
return NULL;
if (utf8 == NULL)
goto cleanup;
- conf = virConfReadMem(utf8, strlen(utf8), VIR_CONF_FLAG_VMX_FORMAT);
+ conf = virConfReadString(utf8, VIR_CONF_FLAG_VMX_FORMAT);
VIR_FREE(utf8);
}
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
- conf = virConfReadMem(config, strlen(config), 0);
+ conf = virConfReadString(config, 0);
if (!conf)
goto cleanup;
"string = \"foo\"\n";
int ret = -1;
- virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0);
+ virConfPtr conf = virConfReadString(srcdata, 0);
int iv;
unsigned int ui;
size_t s;
"string = \"foo\"\n";
int ret = -1;
- virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0);
+ virConfPtr conf = virConfReadString(srcdata, 0);
bool f = true;
bool t = false;
"string = \"foo\"\n";
int ret = -1;
- virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0);
+ virConfPtr conf = virConfReadString(srcdata, 0);
char *str = NULL;
if (!conf)
"string = \"foo\"\n";
int ret = -1;
- virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0);
+ virConfPtr conf = virConfReadString(srcdata, 0);
char **str = NULL;
if (!conf)
if (virTestLoadFile(xlcfg, &xlcfgData) < 0)
goto fail;
- if (!(conf = virConfReadMem(xlcfgData, strlen(xlcfgData), 0)))
+ if (!(conf = virConfReadString(xlcfgData, 0)))
goto fail;
if (!(def = xenParseXL(conf, caps, xmlopt)))
priv.caps = caps;
conn->privateData = &priv;
- if (!(conf = virConfReadMem(xmcfgData, strlen(xmcfgData), 0)))
+ if (!(conf = virConfReadString(xmcfgData, 0)))
goto fail;
if (!(def = xenParseXM(conf, caps, xmlopt)))