コード例 #1
0
ファイル: gatt-db.c プロジェクト: Hibati/gatt
static struct gatt_db_attribute *new_attribute(struct gatt_db_service *service,
							uint16_t handle,
							const bt_uuid_t *type,
							const uint8_t *val,
							uint16_t len)
{
	struct gatt_db_attribute *attribute;

	attribute = new0(struct gatt_db_attribute, 1);

	attribute->service = service;
	attribute->handle = handle;
	attribute->uuid = *type;
	attribute->value_len = len;
	if (len) {
		attribute->value = malloc0(len);
		if (!attribute->value)
			goto failed;

		memcpy(attribute->value, val, len);
	}

	attribute->pending_reads = queue_new();
	attribute->pending_writes = queue_new();

	return attribute;

failed:
	attribute_destroy(attribute);
	return NULL;
}
コード例 #2
0
ファイル: attributes.c プロジェクト: RobertDash/pspp
/* Deletes any attribute from SET that matches NAME
   (case-insensitively). */
void
attrset_delete (struct attrset *set, const char *name)
{
  struct attribute *attr = attrset_lookup (set, name);
  if (attr != NULL)
    {
      hmap_delete (&set->map, &attr->node);
      attribute_destroy (attr);
    }
}
コード例 #3
0
ファイル: attributes.c プロジェクト: RobertDash/pspp
/* Frees the storage associated with SET, if SET is nonnull.
   (Does not free SET itself.) */
void
attrset_destroy (struct attrset *set)
{
  if (set != NULL)
    {
      struct attribute *attr, *next;

      HMAP_FOR_EACH_SAFE (attr, next, struct attribute, node, &set->map)
        attribute_destroy (attr);
      hmap_destroy (&set->map);
    }
}
コード例 #4
0
ファイル: gatt-db.c プロジェクト: Hibati/gatt
static void gatt_db_service_destroy(void *data)
{
	struct gatt_db_service *service = data;
	int i;

	if (service->active)
		notify_service_changed(service->db, service, false);

	for (i = 0; i < service->num_handles; i++)
		attribute_destroy(service->attributes[i]);

	free(service->attributes);
	free(service);
}
コード例 #5
0
ファイル: requirement.c プロジェクト: leckie711/celix
celix_status_t requirement_destroy(requirement_pt requirement) {
	hash_map_iterator_pt attrIter = hashMapIterator_create(requirement->attributes);
	while (hashMapIterator_hasNext(attrIter)) {
		attribute_pt attr = hashMapIterator_nextValue(attrIter);
		hashMapIterator_remove(attrIter);
		attribute_destroy(attr);
	}
	hashMapIterator_destroy(attrIter);
	hashMap_destroy(requirement->attributes, false, false);
	hashMap_destroy(requirement->directives, false, false);

	requirement->attributes = NULL;
	requirement->directives = NULL;

	versionRange_destroy(requirement->versionRange);
	requirement->versionRange = NULL;

	free(requirement);

	return CELIX_SUCCESS;
}