Reindented server/core/hint.c
This commit is contained in:
@ -50,16 +50,26 @@ HINT *nlhead = NULL, *nltail = NULL, *ptr1, *ptr2;
|
|||||||
while (ptr1)
|
while (ptr1)
|
||||||
{
|
{
|
||||||
if ((ptr2 = (HINT *)malloc(sizeof(HINT))) == NULL)
|
if ((ptr2 = (HINT *)malloc(sizeof(HINT))) == NULL)
|
||||||
|
{
|
||||||
return nlhead;
|
return nlhead;
|
||||||
|
}
|
||||||
ptr2->type = ptr1->type;
|
ptr2->type = ptr1->type;
|
||||||
if (ptr1->data)
|
if (ptr1->data)
|
||||||
|
{
|
||||||
ptr2->data = strdup(ptr1->data);
|
ptr2->data = strdup(ptr1->data);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ptr2->data = NULL;
|
ptr2->data = NULL;
|
||||||
|
}
|
||||||
if (ptr1->value)
|
if (ptr1->value)
|
||||||
|
{
|
||||||
ptr2->value = strdup(ptr1->value);
|
ptr2->value = strdup(ptr1->value);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ptr2->value = NULL;
|
ptr2->value = NULL;
|
||||||
|
}
|
||||||
ptr2->next = NULL;
|
ptr2->next = NULL;
|
||||||
if (nltail)
|
if (nltail)
|
||||||
{
|
{
|
||||||
@ -90,13 +100,19 @@ hint_create_route(HINT *head, HINT_TYPE type, char *data)
|
|||||||
HINT *hint;
|
HINT *hint;
|
||||||
|
|
||||||
if ((hint = (HINT *)malloc(sizeof(HINT))) == NULL)
|
if ((hint = (HINT *)malloc(sizeof(HINT))) == NULL)
|
||||||
|
{
|
||||||
return head;
|
return head;
|
||||||
|
}
|
||||||
hint->next = head;
|
hint->next = head;
|
||||||
hint->type = type;
|
hint->type = type;
|
||||||
if (data)
|
if (data)
|
||||||
|
{
|
||||||
hint->data = strdup(data);
|
hint->data = strdup(data);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
hint->data = NULL;
|
hint->data = NULL;
|
||||||
|
}
|
||||||
hint->value = NULL;
|
hint->value = NULL;
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
@ -115,7 +131,9 @@ hint_create_parameter(HINT *head, char *pname, char *value)
|
|||||||
HINT *hint;
|
HINT *hint;
|
||||||
|
|
||||||
if ((hint = (HINT *)malloc(sizeof(HINT))) == NULL)
|
if ((hint = (HINT *)malloc(sizeof(HINT))) == NULL)
|
||||||
|
{
|
||||||
return head;
|
return head;
|
||||||
|
}
|
||||||
hint->next = head;
|
hint->next = head;
|
||||||
hint->type = HINT_PARAMETER;
|
hint->type = HINT_PARAMETER;
|
||||||
hint->data = strdup(pname);
|
hint->data = strdup(pname);
|
||||||
@ -132,14 +150,17 @@ void
|
|||||||
hint_free(HINT *hint)
|
hint_free(HINT *hint)
|
||||||
{
|
{
|
||||||
if (hint->data)
|
if (hint->data)
|
||||||
|
{
|
||||||
free(hint->data);
|
free(hint->data);
|
||||||
|
}
|
||||||
if (hint->value)
|
if (hint->value)
|
||||||
|
{
|
||||||
free(hint->value);
|
free(hint->value);
|
||||||
|
}
|
||||||
free(hint);
|
free(hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hint_exists(
|
bool hint_exists(HINT** p_hint,
|
||||||
HINT** p_hint,
|
|
||||||
HINT_TYPE type)
|
HINT_TYPE type)
|
||||||
{
|
{
|
||||||
bool succp = false;
|
bool succp = false;
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
/**
|
/**
|
||||||
* The types of hint that are supported by the generic hinting mechanism.
|
* The types of hint that are supported by the generic hinting mechanism.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
HINT_ROUTE_TO_MASTER = 1,
|
HINT_ROUTE_TO_MASTER = 1,
|
||||||
HINT_ROUTE_TO_SLAVE,
|
HINT_ROUTE_TO_SLAVE,
|
||||||
HINT_ROUTE_TO_NAMED_SERVER,
|
HINT_ROUTE_TO_NAMED_SERVER,
|
||||||
@ -52,7 +53,8 @@ typedef enum {
|
|||||||
* specific data.
|
* specific data.
|
||||||
* Multiple hints may be attached to a single buffer.
|
* Multiple hints may be attached to a single buffer.
|
||||||
*/
|
*/
|
||||||
typedef struct hint {
|
typedef struct hint
|
||||||
|
{
|
||||||
HINT_TYPE type; /*< The Type of hint */
|
HINT_TYPE type; /*< The Type of hint */
|
||||||
void *data; /*< Type specific data */
|
void *data; /*< Type specific data */
|
||||||
void *value; /*< Parameter value for hint */
|
void *value; /*< Parameter value for hint */
|
||||||
|
Reference in New Issue
Block a user