lib/dgr.c
/** Adds a variable to DGRs list of variables. These variables will be
 * sent to slaves when dgr_update() is called.
 *
 * @param name The name of the variable.
 * @param buffer A pointer to the variable.
 * @param size The number of bytes used by the variable.
 */
Adds a variable to DGRs list of variables. These variables will be
sent to slaves when dgr_update() is called.

@param name The name of the variable.
@param buffer A pointer to the variable.
@param size The number of bytes used by the variable.
Adds a variable to DGRs list of variables . These variables will be sent to slaves when dgr_update () is called . @param name The name of the variable . @param buffer A pointer to the variable . @param size The number of bytes used by the variable .
static void dgr_set(const char *name, const void *buffer, int size)
{
	if(dgr_disabled)
		return;
	int index = dgr_findIndex(name);
	if(index == -1)
	{
		if(dgr_list_size > DGR_MAX_LIST_SIZE)
		{
			msg(MSG_FATAL, "DGR Master: You have exceeded the maximum list size for DGR.");
			exit(EXIT_FAILURE);
		}
		dgr_record *record = &(dgr_list[dgr_list_size]);
		sprintf(record->name, "%s",  name);
		record->size = size;
		record->buffer = malloc(size);
		memcpy(record->buffer, buffer, size);
		dgr_list_size++;
	}
	else
	{
		dgr_record *record = &(dgr_list[index]);
		if(record->size != size)
		{
			free(record->buffer);
			record->buffer = malloc(size);
			record->size = size;
		}
		memcpy(record->buffer, buffer, size);
	}
}
static void dgr_set ( const char * name , const void * buffer , int size ) { if ( dgr_disabled ) return ; int index = dgr_findIndex ( name ) ; if ( index == -1 ) { if ( dgr_list_size > DGR_MAX_LIST_SIZE ) { msg ( MSG_FATAL , " " ) ; exit ( EXIT_FAILURE ) ; } dgr_record * record = & ( dgr_list [ dgr_list_size ] ) ; sprintf ( record -> name , " " , name ) ; record -> size = size ; record -> buffer = malloc ( size ) ; memcpy ( record -> buffer , buffer , size ) ; dgr_list_size ++ ; } else { dgr_record * record = & ( dgr_list [ index ] ) ; if ( record -> size != size ) { free ( record -> buffer ) ; record -> buffer = malloc ( size ) ; record -> size = size ; } memcpy ( record -> buffer , buffer , size ) ; } }
Adds a variable to DGRs list of variables.
Adds a variable to DGRs list of variables .
// printf("dgr_set(%s, %p, %d)\n", name, buffer, size); // printf("DGR Master: The name '%s' is new to dgr, storing it at location %d\n", name, dgr_list_size); // printf("DGR Master: The name '%s' is already known to dgr (at index %d)\n", name, index); //			printf("DGR Master: The name %s used to have size %d but now has size %d.", name, record->size, size);