Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ins before Outs in function parameters.

Testing:
All unit tests passed.
  • Loading branch information...
commit 4a6780f2c1c81433095c83d3a47f7e5328676775 1 parent 2eaef20
Jeremiah Martell authored
View
24 trot/src/trotLib/trot.h
@@ -32,6 +32,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define trot_H
/******************************************************************************/
+#include <stdlib.h> /* for size_t, in memory hook functions */
+
+/******************************************************************************/
typedef enum
{
TROT_LIST_SUCCESS = 0,
@@ -78,14 +81,17 @@ typedef enum
/******************************************************************************/
typedef struct trotListRef_STRUCT trotListRef;
-typedef struct trotListNode_STRUCT trotListNode;
-typedef struct trotList_STRUCT trotList;
-typedef struct trotListRefListNode_STRUCT trotListRefListNode;
+
+/******************************************************************************/
+/* trotHooks.c */
+extern void *(*trotCalloc)( size_t nmemb, size_t size );
+extern void *(*trotMalloc)( size_t size );
+extern void (*trotFree)( void *ptr );
/******************************************************************************/
/* trotListPrimary.c */
TROT_RC trotListRefInit( trotListRef **lr_A );
-TROT_RC trotListRefTwin( trotListRef **lr_A, trotListRef *lrToTwin );
+TROT_RC trotListRefTwin( trotListRef *lr, trotListRef **lrTwin_A );
void trotListRefFree( trotListRef **lr_F );
TROT_RC trotListRefGetCount( trotListRef *lr, INT_TYPE *c );
@@ -96,25 +102,25 @@ TROT_RC trotListRefAppendInt( trotListRef *lr, INT_TYPE n );
TROT_RC trotListRefAppendListTwin( trotListRef *lr, trotListRef *lrToAppend );
TROT_RC trotListRefInsertInt( trotListRef *lr, INT_TYPE index, INT_TYPE n );
-TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef *l );
+TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef *lrToInsert );
TROT_RC trotListRefGetInt( trotListRef *lr, INT_TYPE index, INT_TYPE *n );
-TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **l );
+TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **lrTwin_A );
TROT_RC trotListRefRemoveInt( trotListRef *lr, INT_TYPE index, INT_TYPE *n );
-TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **l );
+TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **lrRemoved_A );
TROT_RC trotListRefRemove( trotListRef *lr, INT_TYPE index );
/******************************************************************************/
/* trotListSecondary.c */
TROT_RC trotListRefCompare( trotListRef *lr, trotListRef *lrCompareTo, TROT_LIST_COMPARE_RESULT *compareResult );
-TROT_RC trotListRefCopy( trotListRef **lrCopy_A, trotListRef *lr );
+TROT_RC trotListRefCopy( trotListRef *lr, trotListRef **lrCopy_A );
TROT_RC trotListRefEnlist( trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd );
TROT_RC trotListRefDelist( trotListRef *lr, INT_TYPE index );
-TROT_RC trotListRefCopySpan( trotListRef **lrCopy_A, trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd );
+TROT_RC trotListRefCopySpan( trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd, trotListRef **lrCopy_A );
TROT_RC trotListRefRemoveSpan( trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd );
/******************************************************************************/
View
33 trot/src/trotLib/trotMem.c → trot/src/trotLib/trotHooks.c
@@ -30,31 +30,40 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/******************************************************************************/
/*!
\file
- Contains our function pointers for:
- Calloc, Malloc, Free
+ Contains hook function pointers for:
+ - Calloc, Malloc, Free
+ - Load
- Used so we can override the standard functions.
+ Used if we're embedded in an app that uses it's own
+ memory functions. We can easily "plug into" their memory management
+ system.
+
+ Used so client can provide a "load" function when we're compiling that
+ we'll use for (include) lists.
Used in our unit tests for testing malloc/calloc failures.
- Also can be useful if we're embedded in an app that uses it's own
- memory functions. We can easily "plug into" their memory management
- system.
*/
/******************************************************************************/
#include <stdlib.h> /* for malloc, calloc, free */
+#include "trot.h"
/******************************************************************************/
/*! This is the function that the library uses for 'calloc'. Used for unit
-testing failed callocs and in case the user of the library has their own memory
-management routines. */
+ testing failed callocs and in case the user of the library has their own
+ memory management routines. */
void *(*trotCalloc)( size_t nmemb, size_t size ) = calloc;
/*! This is the function that the library uses for 'malloc'. Used for unit
-testing failed mallocs and in case the user of the library has their own memory
-management routines. */
+ testing failed mallocs and in case the user of the library has their own
+ memory management routines. */
void *(*trotMalloc)( size_t size ) = malloc;
-/*! This is the function that the library uses for 'free'. Used in case the user
-of the library has their own memory management routines. */
+/*! This is the function that the library uses for 'free'. Used in case the
+ user of the library has their own memory management routines. */
void (*trotFree)( void *ptr ) = free;
+/******************************************************************************/
+/*! This is the function that the library uses to load a (include) when
+ compiling.*/
+TROT_RC (*trotLoad)( trotListRef *lrName, trotListRef **lrCharacters );
+
View
6 trot/src/trotLib/trotInternal.h
@@ -35,8 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h> /* for printf in ERR */
#include <stdlib.h> /* for NULL */
-#include "trotMem.h"
-
/******************************************************************************/
#define NODE_SIZE 64
@@ -87,6 +85,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ERR_IF( POINTER == NULL, TROT_LIST_ERROR_MEMORY_ALLOCATION_FAILED );
/******************************************************************************/
+typedef struct trotListNode_STRUCT trotListNode;
+typedef struct trotList_STRUCT trotList;
+typedef struct trotListRefListNode_STRUCT trotListRefListNode;
+
/*! Data in a trotList is stored in a linked list of trotListNodes. */
struct trotListNode_STRUCT
{
View
54 trot/src/trotLib/trotListPrimary.c
@@ -189,12 +189,12 @@ TROT_RC trotListRefInit( trotListRef **lr_A )
/******************************************************************************/
/*!
\brief Twins a trotListRef reference.
- \param lr_A Pointer to a trotListRef pointer that must be NULL. On
+ \param lr Pointer to the trotListRef pointer to be twinned.
+ \param lrTwin_A Pointer to a trotListRef pointer that must be NULL. On
success, this will point to a new trotListRef reverence.
- \param lrToTwin Pointer to the trotListRef pointer to be twinned.
\return TROT_RC
*/
-TROT_RC trotListRefTwin( trotListRef **lr_A, trotListRef *lrToTwin )
+TROT_RC trotListRefTwin( trotListRef *lr, trotListRef **lrTwin_A )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
@@ -203,23 +203,23 @@ TROT_RC trotListRefTwin( trotListRef **lr_A, trotListRef *lrToTwin )
/* PRECOND */
- PRECOND_ERR_IF( lr_A == NULL );
- PRECOND_ERR_IF( (*lr_A) != NULL );
- PRECOND_ERR_IF( lrToTwin == NULL );
+ PRECOND_ERR_IF( lr == NULL );
+ PRECOND_ERR_IF( lrTwin_A == NULL );
+ PRECOND_ERR_IF( (*lrTwin_A) != NULL );
/* CODE */
TROT_MALLOC( newListRef, trotListRef, 1 );
newListRef -> lParent = NULL;
- newListRef -> lPointsTo = lrToTwin -> lPointsTo;
+ newListRef -> lPointsTo = lr -> lPointsTo;
rc = _refListAdd( newListRef -> lPointsTo, newListRef );
ERR_IF_PASSTHROUGH;
/* give back */
- (*lr_A) = newListRef;
+ (*lrTwin_A) = newListRef;
newListRef = NULL;
return TROT_LIST_SUCCESS;
@@ -557,7 +557,7 @@ TROT_RC trotListRefAppendListTwin( trotListRef *lr, trotListRef *lrToAppend )
}
/* append */
- rc = trotListRefTwin( &newLr, lrToAppend );
+ rc = trotListRefTwin( lrToAppend, &newLr );
ERR_IF_PASSTHROUGH;
node -> l[ node -> count ] = newLr;
@@ -747,10 +747,10 @@ TROT_RC trotListRefInsertInt( trotListRef *lr, INT_TYPE index, INT_TYPE n )
\brief Inserts a twin of a list into the list.
\param lr Pointer to a trotListRef pointer.
\param index Where to insert.
- \param lToInsert The listRef to insert.
+ \param lrToInsert The listRef to insert.
\return TROT_RC
*/
-TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef *lToInsert )
+TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef *lrToInsert )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
@@ -771,7 +771,7 @@ TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef
/* PRECOND */
PRECOND_ERR_IF( lr == NULL );
- PRECOND_ERR_IF( lToInsert == NULL );
+ PRECOND_ERR_IF( lrToInsert == NULL );
/* CODE */
@@ -787,7 +787,7 @@ TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef
list. And two, if they want to add to an empty list. */
if ( index == (l -> childrenCount) + 1 )
{
- rc = trotListRefAppendListTwin( lr, lToInsert );
+ rc = trotListRefAppendListTwin( lr, lrToInsert );
ERR_IF_PASSTHROUGH;
return TROT_LIST_SUCCESS;
@@ -835,7 +835,7 @@ TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef
(count + 1) is the beginning index of the node */
/* *** */
- rc = trotListRefTwin( &newL, lToInsert );
+ rc = trotListRefTwin( lrToInsert, &newL );
ERR_IF_PASSTHROUGH;
/* Now let's move any lists over to make room */
@@ -873,7 +873,7 @@ TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef
node = node -> prev;
/* Insert list into node */
- rc = trotListRefTwin( &newL, lToInsert );
+ rc = trotListRefTwin( lrToInsert, &newL );
ERR_IF_PASSTHROUGH;
node -> l[ node -> count ] = newL;
@@ -901,7 +901,7 @@ TROT_RC trotListRefInsertListTwin( trotListRef *lr, INT_TYPE index, trotListRef
ERR_IF_PASSTHROUGH;
/* *** */
- rc = trotListRefTwin( &newL, lToInsert );
+ rc = trotListRefTwin( lrToInsert, &newL );
ERR_IF_PASSTHROUGH;
/* Insert node into list */
@@ -1019,10 +1019,10 @@ TROT_RC trotListGetInt( trotList *l, INT_TYPE index, INT_TYPE *n )
\brief Gets list ref of list in list.
\param lr Pointer to a trotListRef pointer.
\param index Which list to get.
- \param l On success, will point to list ref.
+ \param lrTwin_A On success, will point to list ref.
\return TROT_RC
*/
-TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **l )
+TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **lrTwin_A )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
@@ -1036,8 +1036,8 @@ TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **l
/* PRECOND */
PRECOND_ERR_IF( lr == NULL );
- PRECOND_ERR_IF( l == NULL );
- PRECOND_ERR_IF( (*l) != NULL );
+ PRECOND_ERR_IF( lrTwin_A == NULL );
+ PRECOND_ERR_IF( (*lrTwin_A) != NULL );
/* CODE */
@@ -1068,11 +1068,11 @@ TROT_RC trotListRefGetListTwin( trotListRef *lr, INT_TYPE index, trotListRef **l
ERR_IF( node -> kind != NODE_KIND_LIST, TROT_LIST_ERROR_WRONG_KIND );
- rc = trotListRefTwin( &newL, node -> l[ (node -> count) - 1 - (count - index) ] );
+ rc = trotListRefTwin( node -> l[ (node -> count) - 1 - (count - index) ], &newL );
ERR_IF_PASSTHROUGH;
/* give back */
- (*l) = newL;
+ (*lrTwin_A) = newL;
newL = NULL;
return TROT_LIST_SUCCESS;
@@ -1176,10 +1176,10 @@ TROT_RC trotListRefRemoveInt( trotListRef *lr, INT_TYPE index, INT_TYPE *n )
\brief Gets and removes list ref of list in list.
\param lr Pointer to a trotListRef pointer.
\param index Which list to get.
- \param l On success, will point to list ref.
+ \param lrRemoved_A On success, will point to list ref.
\return TROT_RC
*/
-TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **l )
+TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **lrRemoved_A )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
@@ -1195,8 +1195,8 @@ TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **l
/* PRECOND */
PRECOND_ERR_IF( lr == NULL );
- PRECOND_ERR_IF( l == NULL );
- PRECOND_ERR_IF( (*l) != NULL );
+ PRECOND_ERR_IF( lrRemoved_A == NULL );
+ PRECOND_ERR_IF( (*lrRemoved_A) != NULL );
/* CODE */
@@ -1249,7 +1249,7 @@ TROT_RC trotListRefRemoveList( trotListRef *lr, INT_TYPE index, trotListRef **l
}
/* give back */
- (*l) = giveBackL;
+ (*lrRemoved_A) = giveBackL;
return TROT_LIST_SUCCESS;
View
18 trot/src/trotLib/trotListSecondary.c
@@ -214,21 +214,21 @@ TROT_RC trotListRefCompare( trotListRef *lr, trotListRef *lrCompareTo, TROT_LIST
/******************************************************************************/
/*!
\brief Copies a list.
+ \param lr Pointer to a trotListRef to copy.
\param lrCopy_A Pointer to a trotListRef pointer that must be NULL.
On success, this will be a copy of the list.
- \param lr Pointer to a trotListRef to copy.
\return TROT_RC
*/
-TROT_RC trotListRefCopy( trotListRef **lrCopy_A, trotListRef *lr )
+TROT_RC trotListRefCopy( trotListRef *lr, trotListRef **lrCopy_A )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
/* PRECOND */
+ PRECOND_ERR_IF( lr == NULL );
PRECOND_ERR_IF( lrCopy_A == NULL );
PRECOND_ERR_IF( (*lrCopy_A) != NULL );
- PRECOND_ERR_IF( lr == NULL );
/* CODE */
@@ -241,7 +241,7 @@ TROT_RC trotListRefCopy( trotListRef **lrCopy_A, trotListRef *lr )
/* else, use CopySpan */
else
{
- rc = trotListRefCopySpan( lrCopy_A, lr, 1, -1 );
+ rc = trotListRefCopySpan( lr, 1, -1, lrCopy_A );
ERR_IF_PASSTHROUGH;
}
@@ -525,7 +525,7 @@ TROT_RC trotListRefDelist( trotListRef *lr, INT_TYPE index )
/* copy our delist (only if it contains something) */
if ( delistListRef -> lPointsTo -> childrenCount > 0 )
{
- rc = trotListRefCopySpan( &copiedListRef, delistListRef, 1, -1 );
+ rc = trotListRefCopySpan( delistListRef, 1, -1, &copiedListRef );
ERR_IF_PASSTHROUGH;
}
@@ -616,14 +616,14 @@ TROT_RC trotListRefDelist( trotListRef *lr, INT_TYPE index )
/******************************************************************************/
/*!
\brief Makes a copy of a span in a list.
- \param lrCopy_A Pointer to a trotListRef pointer that must be NULL.
- On success, this will be a copy of the span.
\param lr Pointer to a trotListRef that you want to copy a span in.
\param indexStart index of start of span.
\param indexEnd index of end of span.
+ \param lrCopy_A Pointer to a trotListRef pointer that must be NULL.
+ On success, this will be a copy of the span.
\return TROT_RC
*/
-TROT_RC trotListRefCopySpan( trotListRef **lrCopy_A, trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd )
+TROT_RC trotListRefCopySpan( trotListRef *lr, INT_TYPE indexStart, INT_TYPE indexEnd, trotListRef **lrCopy_A )
{
/* DATA */
TROT_RC rc = TROT_LIST_SUCCESS;
@@ -643,9 +643,9 @@ TROT_RC trotListRefCopySpan( trotListRef **lrCopy_A, trotListRef *lr, INT_TYPE i
/* PRECOND */
+ PRECOND_ERR_IF( lr == NULL );
PRECOND_ERR_IF( lrCopy_A == NULL );
PRECOND_ERR_IF( (*lrCopy_A) != NULL );
- PRECOND_ERR_IF( lr == NULL );
/* CODE */
View
44 trot/src/trotLib/trotMem.h
@@ -1,44 +0,0 @@
-/*
-Copyright (c) 2010,2011, Jeremiah Martell
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- - Neither the name of Jeremiah Martell nor the name of GeekHorse nor the
- name of Trot nor the names of its contributors may be used to endorse or
- promote products derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/******************************************************************************/
-#ifndef trotMem_H
-#define trotMem_H
-
-/******************************************************************************/
-#include <stdlib.h> /* for size_t */
-
-/******************************************************************************/
-extern void *(*trotCalloc)( size_t nmemb, size_t size );
-extern void *(*trotMalloc)( size_t size );
-extern void (*trotFree)( void *ptr );
-
-/******************************************************************************/
-#endif
-
View
12 trot/src/trotTest/trotTestBadTypesAndIndices.c
@@ -99,12 +99,12 @@ int testBadTypesAndIndices()
TEST_ERR_IF( trotListRefDelist( lr, 11 ) != TROT_LIST_ERROR_BAD_INDEX );
TEST_ERR_IF( trotListRefDelist( lr, 1 ) != TROT_LIST_ERROR_WRONG_KIND );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, 0, 1 ) != TROT_LIST_ERROR_BAD_INDEX );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, -11, 1 ) != TROT_LIST_ERROR_BAD_INDEX );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, 11, 1 ) != TROT_LIST_ERROR_BAD_INDEX );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, 1, 0 ) != TROT_LIST_ERROR_BAD_INDEX );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, 1, -11 ) != TROT_LIST_ERROR_BAD_INDEX );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, lr, 1, 11 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, 0, 1, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, -11, 1, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, 11, 1, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, 1, 0, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, 1, -11, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
+ TEST_ERR_IF( trotListRefCopySpan( lr, 1, 11, &lr2 ) != TROT_LIST_ERROR_BAD_INDEX );
TEST_ERR_IF( trotListRefRemoveSpan( lr, 0, 1 ) != TROT_LIST_ERROR_BAD_INDEX );
TEST_ERR_IF( trotListRefRemoveSpan( lr, -11, 1 ) != TROT_LIST_ERROR_BAD_INDEX );
View
13 trot/src/trotTest/trotTestMemory.c
@@ -30,7 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/******************************************************************************/
#include "trot.h"
#include "trotInternal.h"
-#include "trotMem.h"
#include "trotTestCommon.h"
@@ -192,7 +191,7 @@ static int testMemoryManagement()
if ( r == 0 && i > 0 )
{
j = rand() % i;
- TEST_ERR_IF( trotListRefTwin( &( clientRefs[ i ] ), clientRefs[ j ] ) != TROT_LIST_SUCCESS );
+ TEST_ERR_IF( trotListRefTwin( clientRefs[ j ], &( clientRefs[ i ] ) ) != TROT_LIST_SUCCESS );
}
/* create new list */
else
@@ -217,7 +216,7 @@ static int testMemoryManagement()
else
{
r = rand() % MEMORY_MANAGEMENT_REFS_COUNT;
- TEST_ERR_IF( trotListRefTwin( &ref, clientRefs[ r ] ) != TROT_LIST_SUCCESS );
+ TEST_ERR_IF( trotListRefTwin( clientRefs[ r ], &ref ) != TROT_LIST_SUCCESS );
}
/* how many are we going to add? */
@@ -335,7 +334,7 @@ static int testDeepList()
/* CODE */
TEST_ERR_IF( trotListRefInit( &refHead ) != TROT_LIST_SUCCESS );
- TEST_ERR_IF( trotListRefTwin( &ref1, refHead ) != TROT_LIST_SUCCESS );
+ TEST_ERR_IF( trotListRefTwin( refHead, &ref1 ) != TROT_LIST_SUCCESS );
while ( i < 1000 ) /* MAGIC */
{
@@ -449,7 +448,7 @@ static int testFailedMallocs()
trotListRefFree( &lr2 );
- rc = trotListRefCopy( &lr2, lr1 );
+ rc = trotListRefCopy( lr1, &lr2 );
ERR_IF_PASSTHROUGH;
trotListRefFree( &lr2 );
@@ -460,7 +459,7 @@ static int testFailedMallocs()
rc = trotListRefDelist( lr1, 2 );
ERR_IF_PASSTHROUGH;
- rc = trotListRefCopySpan( &lr2, lr1, 1, -2 );
+ rc = trotListRefCopySpan( lr1, 1, -2, &lr2 );
ERR_IF_PASSTHROUGH;
rc = trotListRefDelist( lr1, -10 );
@@ -472,7 +471,7 @@ static int testFailedMallocs()
/* *** */
rc = trotListRefInit( &lr1 );
ERR_IF_PASSTHROUGH;
- rc = trotListRefCopy( &lr2, lr1 );
+ rc = trotListRefCopy( lr1, &lr2 );
ERR_IF_PASSTHROUGH;
trotListRefFree( &lr1 );
View
18 trot/src/trotTest/trotTestPreconditions.c
@@ -61,9 +61,9 @@ int testPreconditions()
TEST_ERR_IF( trotListRefInit( &lr1 ) != TROT_LIST_SUCCESS );
TEST_ERR_IF( trotListRefInit( &lr1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefTwin( NULL, lr1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefTwin( &lr1, lr1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefTwin( &lr2, NULL ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefTwin( NULL, &lr2 ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefTwin( lr1, NULL ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefTwin( lr1, &lr1 ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefGetCount( NULL, &n ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefGetCount( lr1, NULL ) != TROT_LIST_ERROR_PRECOND );
@@ -105,17 +105,17 @@ int testPreconditions()
TEST_ERR_IF( trotListRefCompare( lr1, NULL, &compareResult ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefCompare( lr1, lr1, NULL ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopy( NULL, lr1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopy( &lr1, lr1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopy( &lr2, NULL ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopy( NULL, &lr2 ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopy( lr1, NULL ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopy( lr1, &lr1 ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefEnlist( NULL, 1, 1 ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefDelist( NULL, 1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopySpan( NULL, lr1, 1, 1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopySpan( &lr1, lr1, 1, 1 ) != TROT_LIST_ERROR_PRECOND );
- TEST_ERR_IF( trotListRefCopySpan( &lr2, NULL, 1, 1 ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopySpan( lr1, 1, 1, NULL ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopySpan( lr1, 1, 1, &lr1 ) != TROT_LIST_ERROR_PRECOND );
+ TEST_ERR_IF( trotListRefCopySpan( NULL, 1, 1, &lr2 ) != TROT_LIST_ERROR_PRECOND );
TEST_ERR_IF( trotListRefRemoveSpan( NULL, 1, 1 ) != TROT_LIST_ERROR_PRECOND );
View
6 trot/src/trotTest/trotTestSecondary.c
@@ -194,7 +194,7 @@ static int testCopyCompare( int (*createFunction)( trotListRef **, int ), int si
TEST_ERR_IF( compare( lr1, lr1, 1 ) != 0 );
/* create copy */
- TEST_ERR_IF( trotListRefCopy( &lr1Copy, lr1 ) != 0 );
+ TEST_ERR_IF( trotListRefCopy( lr1, &lr1Copy ) != 0 );
TEST_ERR_IF( compare( lr1, lr1Copy, 1 ) != 0 );
@@ -221,7 +221,7 @@ static int testCopyCompare( int (*createFunction)( trotListRef **, int ), int si
TEST_ERR_IF( compare( lr1, lr1, 1 ) != 0 );
/* create copy */
- TEST_ERR_IF( trotListRefCopy( &lr1Copy, lr1 ) != 0 );
+ TEST_ERR_IF( trotListRefCopy( lr1, &lr1Copy ) != 0 );
TEST_ERR_IF( compare( lr1, lr1Copy, 1 ) != 0 );
@@ -441,7 +441,7 @@ static int testSpans( int (*createFunction)( trotListRef **, int ), int size )
usedIndex2 = INDEX_TO_NEGATIVE_VERSION_GET_OR_REMOVE( index2, count );
}
- TEST_ERR_IF( trotListRefCopySpan( &lrSpan, lr1, usedIndex1, usedIndex2 ) != 0 );
+ TEST_ERR_IF( trotListRefCopySpan( lr1, usedIndex1, usedIndex2, &lrSpan ) != 0 );
TEST_ERR_IF( checkList( lrSpan ) != 0 );
TEST_ERR_IF( checkList( lr1 ) != 0 );
Please sign in to comment.
Something went wrong with that request. Please try again.