From: Uwe Hermann Date: Sun, 20 Feb 2011 17:39:47 +0000 (+0100) Subject: Add SR_ prefix for MAX_NUM_PROBES/MAX_PROBENAME_LEN. X-Git-Tag: libsigrok-0.1.0~314 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9688b443f65c7779a07b0e3ef2b9f9721ff742cd;p=libsigrok.git Add SR_ prefix for MAX_NUM_PROBES/MAX_PROBENAME_LEN. --- diff --git a/output/output_analog.c b/output/output_analog.c index 0eb897f7..0f60dd35 100644 --- a/output/output_analog.c +++ b/output/output_analog.c @@ -212,7 +212,7 @@ static int data_bits(struct sr_output *o, const char *data_in, char *outbuf, c; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* * Calculate space needed for probes. Set aside 512 bytes for @@ -298,7 +298,7 @@ static int data_hex(struct sr_output *o, const char *data_in, char *outbuf; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 2; outsize = length_in / ctx->unitsize * ctx->num_enabled_probes / ctx->samples_per_line * max_linelen + 512; @@ -363,7 +363,7 @@ static int data_ascii(struct sr_output *o, const char *data_in, char *outbuf; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* * Calculate space needed for probes. Set aside 512 bytes for diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 09a42ad6..43033777 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -27,11 +27,13 @@ struct context { unsigned int num_enabled_probes; unsigned int unitsize; - char *probelist[MAX_NUM_PROBES+1]; + char *probelist[SR_MAX_NUM_PROBES + 1]; char *header; }; -#define MAX_HEADER_LEN 1024 + (MAX_NUM_PROBES * (MAX_PROBENAME_LEN + 10)) +#define MAX_HEADER_LEN \ + (1024 + (SR_MAX_NUM_PROBES * (SR_MAX_PROBENAME_LEN + 10))) + const char *gnuplot_header = "\ # Sample data in space-separated columns format usable by gnuplot\n\ #\n\ diff --git a/output/text/ascii.c b/output/text/ascii.c index e4eacaf3..04d39ea3 100644 --- a/output/text/ascii.c +++ b/output/text/ascii.c @@ -40,7 +40,7 @@ int data_ascii(struct sr_output *o, const char *data_in, uint64_t length_in, char *outbuf; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* * Calculate space needed for probes. Set aside 512 bytes for diff --git a/output/text/bits.c b/output/text/bits.c index ccf55070..43eb7d02 100644 --- a/output/text/bits.c +++ b/output/text/bits.c @@ -40,7 +40,7 @@ int data_bits(struct sr_output *o, const char *data_in, uint64_t length_in, char *outbuf, c; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* * Calculate space needed for probes. Set aside 512 bytes for diff --git a/output/text/hex.c b/output/text/hex.c index 37785af3..bd9aa09d 100644 --- a/output/text/hex.c +++ b/output/text/hex.c @@ -40,7 +40,7 @@ int data_hex(struct sr_output *o, const char *data_in, uint64_t length_in, char *outbuf; ctx = o->internal; - max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 2; outsize = length_in / ctx->unitsize * ctx->num_enabled_probes / ctx->samples_per_line * max_linelen + 512; diff --git a/sigrok.h b/sigrok.h index 6eeca9a3..2eda97ba 100644 --- a/sigrok.h +++ b/sigrok.h @@ -55,9 +55,8 @@ extern "C" { #define SR_ERR_MALLOC -2 /* Malloc/calloc/realloc error */ #define SR_ERR_SAMPLERATE -3 /* Incorrect samplerate */ -/* limited by uint64_t */ -#define MAX_NUM_PROBES 64 -#define MAX_PROBENAME_LEN 32 +#define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */ +#define SR_MAX_PROBENAME_LEN 32 /* Handy little macros */ #define KHZ(n) ((n) * 1000)