X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/bac41a7b9a0a9254fa30f8bb6e6038ab71a483e2..a66d0d4aa363c2f8ee16aee8810732ae89bc0608:/cdsa/cdsa_utilities/cssmlist.cpp diff --git a/cdsa/cdsa_utilities/cssmlist.cpp b/cdsa/cdsa_utilities/cssmlist.cpp index 6c01777e..1bb5176a 100644 --- a/cdsa/cdsa_utilities/cssmlist.cpp +++ b/cdsa/cdsa_utilities/cssmlist.cpp @@ -24,6 +24,7 @@ #endif #include +#include // @@ -51,12 +52,18 @@ ListElement::ListElement(const CssmData &data) Element.Word = data; } -ListElement::ListElement(CssmAllocator &alloc, string s) +ListElement::ListElement(CssmAllocator &alloc, const CssmData &data) +{ + ElementType = CSSM_LIST_ELEMENT_DATUM; + WordID = 0; + Element.Word = CssmAutoData(alloc, data).release(); +} + +ListElement::ListElement(CssmAllocator &alloc, const string &s) { ElementType = CSSM_LIST_ELEMENT_DATUM; WordID = 0; - size_t length = s.size(); - Element.Word = CssmData(memcpy(alloc.alloc(length), s.data(), length), length); + Element.Word = CssmAutoData(alloc, s.data(), s.size()).release(); } ListElement::ListElement(const CssmList &list) @@ -238,6 +245,23 @@ TypedList::TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type, ListElement *e append(elem2); } +TypedList::TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type, ListElement *elem1, ListElement *elem2, ListElement *elem3) +{ + append(new(alloc) ListElement(type)); + append(elem1); + append(elem2); + append(elem3); +} + +TypedList::TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type, ListElement *elem1, ListElement *elem2, ListElement *elem3, ListElement *elem4) +{ + append(new(alloc) ListElement(type)); + append(elem1); + append(elem2); + append(elem3); + append(elem4); +} + // // Verify that a TypedList is "proper", i.e. has a first element of WORDID form