mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 19:40:24 +00:00
fixes warnings with Xcode 14.3 as in previous commit
+ allocate +1 in Log_output buffer - snprintf(MULL, 0...) returns number
of bytes without terminating '\0'. std::string storage isn't guaranteed
to be NULL-terminated (std::string("").at(0) throws an exception). The
buffer is somewhere preallocated 256 which prevents problem but it's
better not to rely upon it.
+ comment out some unused function in LDGM that also triggered the
warning but looked a bit suspicious so it was not clear how to fix
88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
/*
|
|
* =====================================================================================
|
|
*
|
|
* Filename: tanner.cpp
|
|
*
|
|
* Description: Implementation of Tanner graph
|
|
*
|
|
* Version: 1.0
|
|
* Created: 03/01/2012 11:22:55 AM
|
|
* Revision: none
|
|
* Compiler: gcc
|
|
*
|
|
* Author: Milan Kabat (), kabat@ics.muni.cz
|
|
* Company: FI MUNI
|
|
*
|
|
* =====================================================================================
|
|
*/
|
|
|
|
|
|
#include <cstring>
|
|
#include <cstdlib>
|
|
#include <cstdio>
|
|
#include "tanner.h"
|
|
|
|
using namespace std;
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
* Implementation of class Node
|
|
*-----------------------------------------------------------------------------*/
|
|
Node::Node(Tanner_graph * /* tanner */, Node::Node_type t, char *d) {
|
|
// int size = tanner->data_size;
|
|
this->type = t;
|
|
data = d;
|
|
done = false;
|
|
// neighbours[0] = 0;
|
|
// printf("Created node with data: %d\n", *data);
|
|
tanner = nullptr; /// @todo remove, it is no longer used
|
|
}
|
|
|
|
Node::~Node() {
|
|
}
|
|
|
|
#if 0
|
|
// unused and seems quite suspicious (but since it is not called, it is unclear
|
|
// what contents of pointer d is
|
|
int Node::setDataPtr(char *d) {
|
|
|
|
if ( d != 0 ) {
|
|
sprintf(data, d, tanner->data_size);
|
|
return 0;
|
|
} else
|
|
return 1;
|
|
}
|
|
#endif
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
* Implementation fo class Edge
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
Edge::Edge(Node *a, Node *b) {
|
|
first = a;
|
|
second = b;
|
|
}
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
* Implementation fo class Tanner_graph
|
|
*-----------------------------------------------------------------------------*/
|
|
void Tanner_graph::set_data_size(int size) {
|
|
data_size = size;
|
|
}
|
|
|
|
void Tanner_graph::add_node(Node::Node_type type, int index, char *data) {
|
|
// printf("Creating node with data: %d\n", *data);
|
|
|
|
if(data == NULL) {
|
|
// void *d = calloc(data_size, sizeof(char));
|
|
Node n(this, type, data);
|
|
nodes.insert(std::pair <int, Node>(index, n));
|
|
} else {
|
|
Node n(this, type, data);
|
|
nodes.insert(std::pair <int, Node>(index, n));
|
|
}
|
|
}
|
|
|
|
|