mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
util: json: Remove virJSONValueGetArrayAsBitmap
The function is not used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
fd8eeff117
commit
f55031535c
@ -2478,7 +2478,6 @@ virJSONValueArraySteal;
|
|||||||
virJSONValueCopy;
|
virJSONValueCopy;
|
||||||
virJSONValueFree;
|
virJSONValueFree;
|
||||||
virJSONValueFromString;
|
virJSONValueFromString;
|
||||||
virJSONValueGetArrayAsBitmap;
|
|
||||||
virJSONValueGetBoolean;
|
virJSONValueGetBoolean;
|
||||||
virJSONValueGetNumberDouble;
|
virJSONValueGetNumberDouble;
|
||||||
virJSONValueGetNumberInt;
|
virJSONValueGetNumberInt;
|
||||||
|
@ -1174,57 +1174,6 @@ virJSONValueGetBoolean(virJSONValuePtr val,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virJSONValueGetArrayAsBitmap:
|
|
||||||
* @val: JSON array to convert to bitmap
|
|
||||||
* @bitmap: New bitmap is allocated filled and returned via this argument
|
|
||||||
*
|
|
||||||
* Attempts a conversion of a JSON array to a bitmap. The members of the array
|
|
||||||
* must be non-negative integers for the conversion to succeed. This function
|
|
||||||
* does not report libvirt errors so that it can be used to probe that the
|
|
||||||
* array can be represented as a bitmap.
|
|
||||||
*
|
|
||||||
* Returns 0 on success and fills @bitmap; -1 on error and @bitmap is set to
|
|
||||||
* NULL.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
virJSONValueGetArrayAsBitmap(const virJSONValue *val,
|
|
||||||
virBitmapPtr *bitmap)
|
|
||||||
{
|
|
||||||
virJSONValuePtr elem;
|
|
||||||
size_t i;
|
|
||||||
g_autofree unsigned long long *elems = NULL;
|
|
||||||
unsigned long long maxelem = 0;
|
|
||||||
|
|
||||||
*bitmap = NULL;
|
|
||||||
|
|
||||||
if (val->type != VIR_JSON_TYPE_ARRAY)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
elems = g_new0(unsigned long long, val->data.array.nvalues);
|
|
||||||
|
|
||||||
/* first pass converts array members to numbers and finds the maximum */
|
|
||||||
for (i = 0; i < val->data.array.nvalues; i++) {
|
|
||||||
elem = val->data.array.values[i];
|
|
||||||
|
|
||||||
if (elem->type != VIR_JSON_TYPE_NUMBER ||
|
|
||||||
virStrToLong_ullp(elem->data.number, NULL, 10, &elems[i]) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (elems[i] > maxelem)
|
|
||||||
maxelem = elems[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
*bitmap = virBitmapNew(maxelem + 1);
|
|
||||||
|
|
||||||
/* second pass sets the correct bits in the map */
|
|
||||||
for (i = 0; i < val->data.array.nvalues; i++)
|
|
||||||
ignore_value(virBitmapSetBit(*bitmap, elems[i]));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virJSONValuePtr
|
virJSONValuePtr
|
||||||
virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap)
|
virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap)
|
||||||
{
|
{
|
||||||
|
@ -107,8 +107,6 @@ int virJSONValueGetNumberLong(virJSONValuePtr object, long long *value);
|
|||||||
int virJSONValueGetNumberUlong(virJSONValuePtr object, unsigned long long *value);
|
int virJSONValueGetNumberUlong(virJSONValuePtr object, unsigned long long *value);
|
||||||
int virJSONValueGetNumberDouble(virJSONValuePtr object, double *value);
|
int virJSONValueGetNumberDouble(virJSONValuePtr object, double *value);
|
||||||
int virJSONValueGetBoolean(virJSONValuePtr object, bool *value);
|
int virJSONValueGetBoolean(virJSONValuePtr object, bool *value);
|
||||||
int virJSONValueGetArrayAsBitmap(const virJSONValue *val, virBitmapPtr *bitmap)
|
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
||||||
bool virJSONValueIsNull(virJSONValuePtr object);
|
bool virJSONValueIsNull(virJSONValuePtr object);
|
||||||
virJSONValuePtr virJSONValueObjectGetObject(virJSONValuePtr object,
|
virJSONValuePtr virJSONValueObjectGetObject(virJSONValuePtr object,
|
||||||
const char *key);
|
const char *key);
|
||||||
|
Loading…
Reference in New Issue
Block a user