Skip to content

Commit

Permalink
Changing function names for collection API.
Browse files Browse the repository at this point in the history
Patch prepends prefix "col_" to all
functions related to collection.
This caused some formatiing issues
so the alignement was addressed too.
  • Loading branch information
Dmitri Pal authored and sgallagher committed Jul 3, 2009
1 parent be22e71 commit 09c4b07
Show file tree
Hide file tree
Showing 14 changed files with 2,778 additions and 2,698 deletions.
1,122 changes: 560 additions & 562 deletions common/collection/collection.c

Large diffs are not rendered by default.

827 changes: 432 additions & 395 deletions common/collection/collection.h

Large diffs are not rendered by default.

1,512 changes: 757 additions & 755 deletions common/collection/collection_cnv.c

Large diffs are not rendered by default.

182 changes: 96 additions & 86 deletions common/collection/collection_queue.c

Large diffs are not rendered by default.

68 changes: 39 additions & 29 deletions common/collection/collection_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,53 +29,63 @@
#define COL_NAME_QUEUE "queue"

/* Function that creates a queue object */
int create_queue(struct collection_item **queue);
int col_create_queue(struct collection_item **queue);

/* Function that destroys a queue object */
void destroy_queue(struct collection_item *queue);
void col_destroy_queue(struct collection_item *queue);

/* Family of functions that add property to a queue */
/* Put a string property to queue. */
int enqueue_str_property(struct collection_item *queue,
const char *property, char *string, int length);
int col_enqueue_str_property(struct collection_item *queue,
const char *property,
char *string,
int length);
/* Put a binary property to queue. */
int enqueue_binary_property(struct collection_item *queue,
const char *property, void *binary_data, int length);
int col_enqueue_binary_property(struct collection_item *queue,
const char *property,
void *binary_data,
int length);
/* Put an int property to queue. */
int enqueue_int_property(struct collection_item *queue,
const char *property, int number);
int col_enqueue_int_property(struct collection_item *queue,
const char *property,
int number);
/* Put an unsigned int property to queue. */
int enqueue_unsigned_property(struct collection_item *queue,
const char *property, unsigned int number);
int col_enqueue_unsigned_property(struct collection_item *queue,
const char *property,
unsigned int number);
/* Put a long property. */
int enqueue_long_property(struct collection_item *queue,
const char *property, long number);
int col_enqueue_long_property(struct collection_item *queue,
const char *property,
long number);
/* Put an unsigned long property. */
int enqueue_ulong_property(struct collection_item *queue,
const char *property, unsigned long number);
int col_enqueue_ulong_property(struct collection_item *queue,
const char *property,
unsigned long number);
/* Put a double property. */
int enqueue_double_property(struct collection_item *queue,
const char *property, double number);
int col_enqueue_double_property(struct collection_item *queue,
const char *property,
double number);
/* Put a bool property. */
int enqueue_bool_property(struct collection_item *queue,
const char *property, unsigned char logical);
int col_enqueue_bool_property(struct collection_item *queue,
const char *property,
unsigned char logical);

/* Put any property */
int enqueue_any_property(struct collection_item *queue, /* Queue */
const char *property, /* Name */
int type, /* Data type */
void *data, /* Pointer to the data */
int length); /* Length of the data. For
strings it includes the
trailing 0 */
int col_enqueue_any_property(struct collection_item *queue, /* Queue */
const char *property, /* Name */
int type, /* Data type */
void *data, /* Pointer to the data */
int length); /* Length of the data. For
* strings it includes the
* trailing 0 */
/* Push item */
int enqueue_item(struct collection_item *queue,
struct collection_item *item);
int col_enqueue_item(struct collection_item *queue,
struct collection_item *item);


/* Get item from queue */
int dequeue_item(struct collection_item *queue,
struct collection_item **item);
int col_dequeue_item(struct collection_item *queue,
struct collection_item **item);


#endif
36 changes: 18 additions & 18 deletions common/collection/collection_queue_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ int queue_test()

printf("\n\nQUEUE TEST!!!.\n\n\n");

if((error = create_queue(&queue)) ||
(error = enqueue_str_property(queue, "item1","value 1" ,0)) ||
(error = enqueue_int_property(queue, "item2", -1)) ||
(error = enqueue_unsigned_property(queue, "item3", 1)) ||
(error = enqueue_long_property(queue, "item4", 100)) ||
(error = enqueue_ulong_property(queue, "item5", 1000)) ||
(error = enqueue_double_property(queue, "item6", 1.1)) ||
(error = enqueue_bool_property(queue, "item7", 1)) ||
(error = enqueue_binary_property(queue, "item8", binary_dump, sizeof(binary_dump)))) {
if((error = col_create_queue(&queue)) ||
(error = col_enqueue_str_property(queue, "item1","value 1" ,0)) ||
(error = col_enqueue_int_property(queue, "item2", -1)) ||
(error = col_enqueue_unsigned_property(queue, "item3", 1)) ||
(error = col_enqueue_long_property(queue, "item4", 100)) ||
(error = col_enqueue_ulong_property(queue, "item5", 1000)) ||
(error = col_enqueue_double_property(queue, "item6", 1.1)) ||
(error = col_enqueue_bool_property(queue, "item7", 1)) ||
(error = col_enqueue_binary_property(queue, "item8", binary_dump, sizeof(binary_dump)))) {
printf("Failed to enqueue property. Error %d\n", error);
destroy_collection(queue);
col_destroy_collection(queue);
return error;
}

debug_collection(queue,COL_TRAVERSE_DEFAULT);
col_debug_collection(queue,COL_TRAVERSE_DEFAULT);

error = get_collection_count(queue, &count);
error = col_get_collection_count(queue, &count);
if (error) {
printf("Failed to get count. Error %d\n", error);
destroy_collection(queue);
col_destroy_collection(queue);
return error;
}

Expand All @@ -70,16 +70,16 @@ int queue_test()
printf("Rotate the queue.\n");

for (i = 0; i < count; i++) {
if ((error = dequeue_item(queue, &item)) ||
(error = enqueue_item(queue, item))) {
if ((error = col_dequeue_item(queue, &item)) ||
(error = col_enqueue_item(queue, item))) {
printf("Failed to dequeue or enqueue items. Error %d\n", error);
destroy_collection(queue);
col_destroy_collection(queue);
return error;
}
debug_collection(queue,COL_TRAVERSE_DEFAULT);
col_debug_collection(queue,COL_TRAVERSE_DEFAULT);
}

destroy_collection(queue);
col_destroy_collection(queue);
TRACE_FLOW_NUMBER("queue_test. Returning", error);

printf("\n\nEND OF QUEUE TEST!!!.\n\n\n");
Expand Down
Loading

0 comments on commit 09c4b07

Please sign in to comment.