freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master ef3bf14: * src/strbuf.c (strbuf_init): Adjust t


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ef3bf14: * src/strbuf.c (strbuf_init): Adjust to fix `FTDemo_Version'.
Date: Sat, 17 Oct 2020 12:48:33 -0400 (EDT)

branch: master
commit ef3bf148249f9c1f76d3c41c8a6816a21434ea75
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    * src/strbuf.c (strbuf_init): Adjust to fix `FTDemo_Version'.
    * src/ftcommon.[ch] (FTDemo_Version): Clarify argument.
---
 ChangeLog      | 5 +++++
 src/ftcommon.c | 6 +++---
 src/ftcommon.h | 2 +-
 src/strbuf.c   | 3 +--
 src/strbuf.h   | 2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2ddc8b6..a41fe82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-17  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/strbuf.c (strbuf_init): Adjust to fix `FTDemo_Version'.
+       * src/ftcommon.[ch] (FTDemo_Version): Clarify argument.
+
 2020-10-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        [ftgrid,ftview,ftstring] Add icons.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 44e4214..4451032 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -553,7 +553,7 @@
 
   void
   FTDemo_Version( FTDemo_Handle*  handle,
-                  FT_String*      str )
+                  FT_String       str[64] )
   {
     FT_Int     major, minor, patch;
     FT_String  format[] = "%d.%d.%d";
@@ -566,7 +566,7 @@
       format[5] = '\0';   /* terminate early */
 
     /* append the version string */
-    strbuf_init( &sb, str, sizeof ( str ) );
+    strbuf_init( &sb, str, 64 );
     strbuf_format( &sb, format, major, minor, patch );
   }
 
@@ -1034,7 +1034,7 @@
                       int              error_code )
   {
     FT_Face      face;
-    char         buffer[256];
+    char         buffer[256] = "";
     StrBuf       buf[1];
     const char*  basename;
     int          ppem;
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 4565dc2..39ced9e 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -243,7 +243,7 @@
   /* append version information */
   void
   FTDemo_Version( FTDemo_Handle*  handle,
-                  FT_String*      str );
+                  FT_String       str[64] );
 
 
   /* add FT window icon */
diff --git a/src/strbuf.c b/src/strbuf.c
index 81dfc37..7fe65bb 100644
--- a/src/strbuf.c
+++ b/src/strbuf.c
@@ -25,10 +25,9 @@
   {
     assert( buffer_len > 0 );
 
-    sb->pos    = 0;
+    sb->pos    = strlen( buffer );
     sb->limit  = buffer_len - 1;  /* Reserve one char. for the final '\0'. */
     sb->buffer = buffer;
-    buffer[0]  = '\0';
   }
 
 
diff --git a/src/strbuf.h b/src/strbuf.h
index 4c4ab63..2f7913a 100644
--- a/src/strbuf.h
+++ b/src/strbuf.h
@@ -46,7 +46,7 @@ extern "C" {
   /*
    * Initialize a `StrBuf' instance that allows to append strings to
    * `buffer'.  Note that `buffer_len' *must* be > 0, or the behaviour is
-   * undefined.
+   * undefined.  The `buffer' content must be null-terminated.
    */
   extern void
   strbuf_init( StrBuf*  sb,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]