summaryrefslogtreecommitdiffstats
path: root/src/base/ftutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/ftutil.c')
-rw-r--r--src/base/ftutil.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index 9f37189..f5b72db 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002, 2004-2007, 2013 by */
+/* Copyright 2002-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -180,7 +180,7 @@
FT_Error *p_error )
{
FT_Error error;
- FT_Pointer p = ft_mem_qalloc( memory, size, &error );
+ FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error );
if ( !error && address )
@@ -245,6 +245,9 @@
FT_ListNode cur;
+ if ( !list )
+ return NULL;
+
cur = list->head;
while ( cur )
{
@@ -254,7 +257,7 @@
cur = cur->next;
}
- return (FT_ListNode)0;
+ return NULL;
}
@@ -264,10 +267,15 @@
FT_List_Add( FT_List list,
FT_ListNode node )
{
- FT_ListNode before = list->tail;
+ FT_ListNode before;
+
+ if ( !list || !node )
+ return;
- node->next = 0;
+ before = list->tail;
+
+ node->next = NULL;
node->prev = before;
if ( before )
@@ -285,11 +293,16 @@
FT_List_Insert( FT_List list,
FT_ListNode node )
{
- FT_ListNode after = list->head;
+ FT_ListNode after;
+ if ( !list || !node )
+ return;
+
+ after = list->head;
+
node->next = after;
- node->prev = 0;
+ node->prev = NULL;
if ( !after )
list->tail = node;
@@ -309,6 +322,9 @@
FT_ListNode before, after;
+ if ( !list || !node )
+ return;
+
before = node->prev;
after = node->next;
@@ -333,6 +349,9 @@
FT_ListNode before, after;
+ if ( !list || !node )
+ return;
+
before = node->prev;
after = node->next;
@@ -347,7 +366,7 @@
else
list->tail = before;
- node->prev = 0;
+ node->prev = NULL;
node->next = list->head;
list->head->prev = node;
list->head = node;
@@ -357,14 +376,19 @@
/* documentation is in ftlist.h */
FT_EXPORT_DEF( FT_Error )
- FT_List_Iterate( FT_List list,
- FT_List_Iterator iterator,
- void* user )
+ FT_List_Iterate( FT_List list,
+ FT_List_Iterator iterator,
+ void* user )
{
- FT_ListNode cur = list->head;
+ FT_ListNode cur;
FT_Error error = FT_Err_Ok;
+ if ( !list || !iterator )
+ return FT_THROW( Invalid_Argument );
+
+ cur = list->head;
+
while ( cur )
{
FT_ListNode next = cur->next;
@@ -392,6 +416,9 @@
FT_ListNode cur;
+ if ( !list || !memory )
+ return;
+
cur = list->head;
while ( cur )
{
@@ -406,8 +433,8 @@
cur = next;
}
- list->head = 0;
- list->tail = 0;
+ list->head = NULL;
+ list->tail = NULL;
}