plist functions that add objects return qboolean, not int. Also doc fixes.

This commit is contained in:
Jeff Teunissen 2004-01-07 07:01:31 +00:00
parent efd6ccff02
commit eb6b179add
2 changed files with 17 additions and 16 deletions

View file

@ -157,9 +157,9 @@ plitem_t *PL_D_AllKeys (plitem_t *);
//@{
/**
\fn plitem_t *PL_D_AddObject (plitem_t *dict, plitem_t *key, plitem_t *value)
\fn plitem_t *PL_A_AddObject (plitem_t *array, plitem_t *item)
\fn plitem_t *PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int ind)
\fn qboolean PL_D_AddObject (plitem_t *dict, plitem_t *key, plitem_t *value)
\fn qboolean PL_A_AddObject (plitem_t *array, plitem_t *item)
\fn qboolean PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int ind)
\param dict The dictionary to add the key/value pair to
\param array The array to add the item to
@ -171,9 +171,9 @@ plitem_t *PL_D_AllKeys (plitem_t *);
Note: the dictionary or array becomes the owner of the added item/pair.
*/
int PL_D_AddObject (plitem_t *, plitem_t *, plitem_t *);
int PL_A_AddObject (plitem_t *, plitem_t *);
int PL_A_InsertObjectAtIndex (plitem_t *, plitem_t *, int ind);
qboolean PL_D_AddObject (plitem_t *, plitem_t *, plitem_t *);
qboolean PL_A_AddObject (plitem_t *, plitem_t *);
qboolean PL_A_InsertObjectAtIndex (plitem_t *, plitem_t *, int ind);
//@}
plitem_t *PL_NewDictionary (void);

View file

@ -190,16 +190,16 @@ PL_ObjectAtIndex (plitem_t *item, int index)
return index >= 0 && index < array->numvals ? array->values[index] : NULL;
}
int
qboolean
PL_D_AddObject (plitem_t *dict, plitem_t *key, plitem_t *value)
{
dictkey_t *k;
if (dict->type != QFDictionary)
return 0;
return false;
if (key->type != QFString)
return 0;
return false;
if ((k = Hash_Find ((hashtab_t *)dict->data, key->data))) {
PL_Free ((plitem_t *) k->value);
@ -208,14 +208,14 @@ PL_D_AddObject (plitem_t *dict, plitem_t *key, plitem_t *value)
k = malloc (sizeof (dictkey_t));
if (!k)
return 0;
return false;
k->key = strdup ((char *) key->data);
k->value = value;
Hash_Add ((hashtab_t *)dict->data, k);
}
return 1;
return true;
}
int
@ -224,7 +224,7 @@ PL_A_InsertObjectAtIndex (plitem_t *array_item, plitem_t *item, int index)
plarray_t *array;
if (array_item->type != QFArray)
return 0;
return false;
array = (plarray_t *)array_item->data;
@ -233,7 +233,8 @@ PL_A_InsertObjectAtIndex (plitem_t *array_item, plitem_t *item, int index)
plitem_t **tmp = realloc (array->values, size);
if (!tmp)
return 0;
return false;
array->maxvals += 128;
array->values = tmp;
memset (array->values + array->numvals, 0,
@ -244,16 +245,16 @@ PL_A_InsertObjectAtIndex (plitem_t *array_item, plitem_t *item, int index)
index = array->numvals;
if (index < 0 || index > array->numvals)
return 0;
return false;
memmove (array->values + index + 1, array->values + index,
(array->numvals - index) * sizeof (plitem_t *));
array->values[index] = item;
array->numvals++;
return 1;
return true;
}
int
qboolean
PL_A_AddObject (plitem_t *array_item, plitem_t *item)
{
return PL_A_InsertObjectAtIndex (array_item, item, -1);