[postgis-tickets] r17537 - Bytebuffer: Ifdef unused code
Raul
raul at rmr.ninja
Wed Jun 19 04:57:19 PDT 2019
Author: algunenano
Date: 2019-06-19 04:57:19 -0700 (Wed, 19 Jun 2019)
New Revision: 17537
Modified:
trunk/liblwgeom/bytebuffer.c
trunk/liblwgeom/bytebuffer.h
Log:
Bytebuffer: Ifdef unused code
Raises the coverage of the file
I was going to delete it, but convinced otherwise
Modified: trunk/liblwgeom/bytebuffer.c
===================================================================
--- trunk/liblwgeom/bytebuffer.c 2019-06-18 15:33:32 UTC (rev 17536)
+++ trunk/liblwgeom/bytebuffer.c 2019-06-19 11:57:19 UTC (rev 17537)
@@ -27,43 +27,8 @@
#include "liblwgeom_internal.h"
#include "bytebuffer.h"
-/**
-* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
-*/
-bytebuffer_t*
-bytebuffer_create(void)
-{
- LWDEBUG(2,"Entered bytebuffer_create");
- return bytebuffer_create_with_size(BYTEBUFFER_STARTSIZE);
-}
/**
-* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
-*/
-bytebuffer_t*
-bytebuffer_create_with_size(size_t size)
-{
- LWDEBUGF(2,"Entered bytebuffer_create_with_size %d", size);
- bytebuffer_t *s;
-
- s = lwalloc(sizeof(bytebuffer_t));
- if ( size < BYTEBUFFER_STATICSIZE )
- {
- s->capacity = BYTEBUFFER_STATICSIZE;
- s->buf_start = s->buf_static;
- }
- else
- {
- s->buf_start = lwalloc(size);
- s->capacity = size;
- }
- s->readcursor = s->writecursor = s->buf_start;
- memset(s->buf_start,0,s->capacity);
- LWDEBUGF(4,"We create a buffer on %p of %d bytes", s->buf_start, s->capacity);
- return s;
-}
-
-/**
* Allocate just the internal buffer of an existing bytebuffer_t
* struct. Useful for allocating short-lived bytebuffers off the stack.
*/
@@ -88,19 +53,6 @@
* Free the bytebuffer_t and all memory managed within it.
*/
void
-bytebuffer_destroy(bytebuffer_t *s)
-{
- bytebuffer_destroy_buffer(s);
- if ( s )
- lwfree(s);
-
- return;
-}
-
-/**
-* Free the bytebuffer_t and all memory managed within it.
-*/
-void
bytebuffer_destroy_buffer(bytebuffer_t *s)
{
if ( s->buf_start != s->buf_static )
@@ -113,26 +65,6 @@
}
/**
-* Set the read cursor to the beginning
-*/
-void
-bytebuffer_reset_reading(bytebuffer_t *s)
-{
- s->readcursor = s->buf_start;
-}
-
-/**
-* Reset the bytebuffer_t. Useful for starting a fresh string
-* without the expense of freeing and re-allocating a new
-* bytebuffer_t.
-*/
-void
-bytebuffer_clear(bytebuffer_t *s)
-{
- s->readcursor = s->writecursor = s->buf_start;
-}
-
-/**
* If necessary, expand the bytebuffer_t internal buffer to accomodate the
* specified additional size.
*/
@@ -189,7 +121,6 @@
return s->buf_start;
}
-
/**
* Writes a uint8_t value to the buffer
*/
@@ -203,24 +134,10 @@
return;
}
-
/**
* Writes a uint8_t value to the buffer
*/
void
-bytebuffer_append_bulk(bytebuffer_t *s, void * start, size_t size)
-{
- LWDEBUGF(2,"bytebuffer_append_bulk with size %d",size);
- bytebuffer_makeroom(s, size);
- memcpy(s->writecursor, start, size);
- s->writecursor += size;
- return;
-}
-
-/**
-* Writes a uint8_t value to the buffer
-*/
-void
bytebuffer_append_bytebuffer(bytebuffer_t *write_to,bytebuffer_t *write_from )
{
LWDEBUG(2,"bytebuffer_append_bytebuffer");
@@ -231,7 +148,6 @@
return;
}
-
/**
* Writes a signed varInt to the buffer
*/
@@ -254,7 +170,100 @@
return;
}
+/**
+ * Returns the length of the current buffer
+ */
+size_t
+bytebuffer_getlength(const bytebuffer_t *s)
+{
+ return (size_t)(s->writecursor - s->buf_start);
+}
+/* Unused functions */
+#if 0
+
+/**
+* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
+*/
+bytebuffer_t*
+bytebuffer_create(void)
+{
+ LWDEBUG(2,"Entered bytebuffer_create");
+ return bytebuffer_create_with_size(BYTEBUFFER_STARTSIZE);
+}
+
+ /**
+* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
+*/
+bytebuffer_t*
+bytebuffer_create_with_size(size_t size)
+{
+ LWDEBUGF(2,"Entered bytebuffer_create_with_size %d", size);
+ bytebuffer_t *s;
+
+ s = lwalloc(sizeof(bytebuffer_t));
+ if ( size < BYTEBUFFER_STATICSIZE )
+ {
+ s->capacity = BYTEBUFFER_STATICSIZE;
+ s->buf_start = s->buf_static;
+ }
+ else
+ {
+ s->buf_start = lwalloc(size);
+ s->capacity = size;
+ }
+ s->readcursor = s->writecursor = s->buf_start;
+ memset(s->buf_start,0,s->capacity);
+ LWDEBUGF(4,"We create a buffer on %p of %d bytes", s->buf_start, s->capacity);
+ return s;
+}
+
+/**
+* Free the bytebuffer_t and all memory managed within it.
+*/
+void
+bytebuffer_destroy(bytebuffer_t *s)
+{
+ bytebuffer_destroy_buffer(s);
+ if ( s )
+ lwfree(s);
+
+ return;
+}
+
+/**
+* Set the read cursor to the beginning
+*/
+void
+bytebuffer_reset_reading(bytebuffer_t *s)
+{
+ s->readcursor = s->buf_start;
+}
+
+ /**
+* Reset the bytebuffer_t. Useful for starting a fresh string
+* without the expense of freeing and re-allocating a new
+* bytebuffer_t.
+*/
+void
+bytebuffer_clear(bytebuffer_t *s)
+{
+ s->readcursor = s->writecursor = s->buf_start;
+}
+
+/**
+* Writes a uint8_t value to the buffer
+*/
+void
+bytebuffer_append_bulk(bytebuffer_t *s, void * start, size_t size)
+{
+ LWDEBUGF(2,"bytebuffer_append_bulk with size %d",size);
+ bytebuffer_makeroom(s, size);
+ memcpy(s->writecursor, start, size);
+ s->writecursor += size;
+ return;
+}
+
/*
* Writes Integer to the buffer
*/
@@ -294,13 +303,13 @@
LWDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
return;
-}
+ }
-/**
+ /**
* Writes a float64 to the buffer
*/
void
@@ -340,9 +349,9 @@
LWDEBUG(4,"Return from bytebuffer_append_double");
return;
-}
+ }
-/**
+ /**
* Reads a signed varInt from the buffer
*/
int64_t
@@ -354,7 +363,7 @@
return val;
}
-/**
+ /**
* Reads a unsigned varInt from the buffer
*/
uint64_t
@@ -366,17 +375,8 @@
return val;
}
-/**
-* Returns the length of the current buffer
-*/
-size_t
-bytebuffer_getlength(const bytebuffer_t *s)
-{
- return (size_t) (s->writecursor - s->buf_start);
-}
-
-/**
+ /**
* Returns a new bytebuffer were both ingoing bytebuffers is merged.
* Caller is responsible for freeing both incoming bytebuffers and resulting bytebuffer
*/
@@ -402,4 +402,4 @@
return res;
}
-
+#endif
Modified: trunk/liblwgeom/bytebuffer.h
===================================================================
--- trunk/liblwgeom/bytebuffer.h 2019-06-18 15:33:32 UTC (rev 17536)
+++ trunk/liblwgeom/bytebuffer.h 2019-06-19 11:57:19 UTC (rev 17537)
@@ -46,24 +46,29 @@
bytebuffer_t;
void bytebuffer_init_with_size(bytebuffer_t *b, size_t size);
-bytebuffer_t *bytebuffer_create_with_size(size_t size);
-bytebuffer_t *bytebuffer_create(void);
-void bytebuffer_destroy(bytebuffer_t *s);
void bytebuffer_destroy_buffer(bytebuffer_t *s);
-void bytebuffer_clear(bytebuffer_t *s);
void bytebuffer_append_byte(bytebuffer_t *s, const uint8_t val);
+void bytebuffer_append_bytebuffer(bytebuffer_t *write_to, bytebuffer_t *write_from);
void bytebuffer_append_varint(bytebuffer_t *s, const int64_t val);
void bytebuffer_append_uvarint(bytebuffer_t *s, const uint64_t val);
+size_t bytebuffer_getlength(const bytebuffer_t *s);
+uint8_t* bytebuffer_get_buffer_copy(const bytebuffer_t *s, size_t *buffer_length);
+const uint8_t* bytebuffer_get_buffer(const bytebuffer_t *s, size_t *buffer_length);
+
+/* Unused functions */
+#if 0
+void bytebuffer_destroy(bytebuffer_t *s);
+bytebuffer_t *bytebuffer_create_with_size(size_t size);
+bytebuffer_t *bytebuffer_create(void);
+void bytebuffer_clear(bytebuffer_t *s);
uint64_t bytebuffer_read_uvarint(bytebuffer_t *s);
int64_t bytebuffer_read_varint(bytebuffer_t *s);
-size_t bytebuffer_getlength(const bytebuffer_t *s);
bytebuffer_t* bytebuffer_merge(bytebuffer_t **buff_array, int nbuffers);
void bytebuffer_reset_reading(bytebuffer_t *s);
-uint8_t* bytebuffer_get_buffer_copy(const bytebuffer_t *s, size_t *buffer_length);
-const uint8_t* bytebuffer_get_buffer(const bytebuffer_t *s, size_t *buffer_length);
-
void bytebuffer_append_bytebuffer(bytebuffer_t *write_to,bytebuffer_t *write_from);
void bytebuffer_append_bulk(bytebuffer_t *s, void * start, size_t size);
void bytebuffer_append_int(bytebuffer_t *buf, const int val, int swap);
void bytebuffer_append_double(bytebuffer_t *buf, const double val, int swap);
+#endif
+
#endif /* _BYTEBUFFER_H */
More information about the postgis-tickets
mailing list