summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c76
1 files changed, 28 insertions, 48 deletions
diff --git a/src/list.c b/src/list.c
index 40650caf..03208bba 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1,13 +1,18 @@
-/**
+/*
* XML Security Library (http://www.aleksey.com/xmlsec).
*
- * List of pointers.
*
* This is free software; see Copyright file in the source
* distribution for preciese wording.
- *
* Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
*/
+/**
+ * SECTION:list
+ * @Short_description: Generic list structure functions.
+ * @Stability: Stable
+ *
+ */
+
#include "globals.h"
#include <stdlib.h>
@@ -19,7 +24,6 @@
#include <xmlsec/list.h>
#include <xmlsec/errors.h>
-
static int xmlSecPtrListEnsureSize (xmlSecPtrListPtr list,
xmlSecSize size);
@@ -60,22 +64,15 @@ xmlSecPtrListCreate(xmlSecPtrListId id) {
/* Allocate a new xmlSecPtrList and fill the fields. */
list = (xmlSecPtrListPtr)xmlMalloc(sizeof(xmlSecPtrList));
if(list == NULL) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListKlassGetName(id)),
- NULL,
- XMLSEC_ERRORS_R_MALLOC_FAILED,
- "sizeof(xmlSecPtrList)=%d",
- (int)sizeof(xmlSecPtrList));
+ xmlSecMallocError(sizeof(xmlSecPtrList),
+ xmlSecPtrListKlassGetName(id));
return(NULL);
}
ret = xmlSecPtrListInitialize(list, id);
if(ret < 0) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListKlassGetName(id)),
- "xmlSecPtrListInitialize",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ xmlSecInternalError("xmlSecPtrListInitialize",
+ xmlSecPtrListKlassGetName(id));
xmlFree(list);
return(NULL);
}
@@ -186,11 +183,9 @@ xmlSecPtrListCopy(xmlSecPtrListPtr dst, xmlSecPtrListPtr src) {
/* allocate memory */
ret = xmlSecPtrListEnsureSize(dst, dst->use + src->use);
if(ret < 0) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(src)),
- "xmlSecPtrListEnsureSize",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- "size=%d", src->use);
+ xmlSecInternalError2("xmlSecPtrListEnsureSize",
+ xmlSecPtrListGetName(src),
+ "size=%d", src->use);
return(-1);
}
@@ -202,11 +197,8 @@ xmlSecPtrListCopy(xmlSecPtrListPtr dst, xmlSecPtrListPtr src) {
if((dst->id->duplicateItem != NULL) && (src->data[i] != NULL)) {
dst->data[dst->use] = dst->id->duplicateItem(src->data[i]);
if(dst->data[dst->use] == NULL) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(src)),
- "duplicateItem",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ xmlSecInternalError("duplicateItem",
+ xmlSecPtrListGetName(src));
return(-1);
}
} else {
@@ -234,21 +226,15 @@ xmlSecPtrListDuplicate(xmlSecPtrListPtr list) {
newList = xmlSecPtrListCreate(list->id);
if(newList == NULL) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(list)),
- "xmlSecPtrListCreate",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ xmlSecInternalError("xmlSecPtrListCreate",
+ xmlSecPtrListGetName(list));
return(NULL);
}
ret = xmlSecPtrListCopy(newList, list);
if(ret < 0) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(list)),
- "xmlSecPtrListCopy",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ xmlSecInternalError("xmlSecPtrListCopy",
+ xmlSecPtrListGetName(list));
xmlSecPtrListDestroy(newList);
return(NULL);
}
@@ -261,7 +247,7 @@ xmlSecPtrListDuplicate(xmlSecPtrListPtr list) {
*
* Gets list size.
*
- * Returns: the number of itmes in @list.
+ * Returns: the number of items in @list.
*/
xmlSecSize
xmlSecPtrListGetSize(xmlSecPtrListPtr list) {
@@ -306,11 +292,9 @@ xmlSecPtrListAdd(xmlSecPtrListPtr list, xmlSecPtr item) {
ret = xmlSecPtrListEnsureSize(list, list->use + 1);
if(ret < 0) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(list)),
- "xmlSecPtrListAdd",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- "size=%d", list->use + 1);
+ xmlSecInternalError2("xmlSecPtrListEnsureSize",
+ xmlSecPtrListGetName(list),
+ "size=%d", list->use + 1);
return(-1);
}
@@ -474,12 +458,8 @@ xmlSecPtrListEnsureSize(xmlSecPtrListPtr list, xmlSecSize size) {
newData = (xmlSecPtr*)xmlMalloc(sizeof(xmlSecPtr) * newSize);
}
if(newData == NULL) {
- xmlSecError(XMLSEC_ERRORS_HERE,
- xmlSecErrorsSafeString(xmlSecPtrListGetName(list)),
- NULL,
- XMLSEC_ERRORS_R_MALLOC_FAILED,
- "sizeof(xmlSecPtr)*%d=%d",
- newSize, (int)(sizeof(xmlSecPtr) * newSize));
+ xmlSecMallocError(sizeof(xmlSecPtr) * newSize,
+ xmlSecPtrListGetName(list));
return(-1);
}
@@ -508,7 +488,7 @@ static xmlSecPtrListKlass xmlSecStringListKlass = {
/**
* xmlSecStringListGetKlass:
*
- * The strins list class.
+ * The strings list class.
*
* Returns: strings list klass.
*/