]> granicus.if.org Git - graphviz/commitdiff
deal exclusively in size_t in Java bindings support code
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 11 Jul 2021 02:42:24 +0000 (19:42 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Jul 2021 18:36:52 +0000 (11:36 -0700)
In this code, committed in c7374588519a7ac557c14b38c147623dedf43fdb in 2014, it
is not clear to me why int was used. The correct type for these kind of
operations is size_t. The size_t type has been available since at least 1995, if
not earlier depending on your toolchain. Squashes 3
-Wsign-conversion/-Wconversion warnings.

tclpkg/gv/gv_java_init.c

index 54b4f2e4632a4edafaa74f3f2cd75c553bd65d7b..66193d11a86c953381fdc6f3f22107809af1abfd 100644 (file)
 
 typedef struct {
     char* data;
-    int sz;       /* buffer size */
-    int len;      /* length of array */
+    size_t sz;       /* buffer size */
+    size_t len;      /* length of array */
 } BA;
 
 static size_t gv_string_writer(GVJ_t *job, const char *s, size_t len)
 {
     BA* bap = (BA*)(job->output_file);
-/* fprintf (stderr, "newlen %ld data %p sz %d len %d\n", len, bap->data,bap->sz, bap->len); */
-    int newlen = bap->len + len;
+    size_t newlen = bap->len + len;
     if (newlen > bap->sz) {
        bap->sz *= 2;
        if (newlen > bap->sz)