Skip to content

localString returns a structur by value and no pointer. #1

Description

@kwrtz

localString returns a structur by value and no pointer. Therefore the example is wrong:

      #define SIZE 40   <--- the LString can never grow longer than 39 chars
      static char buff[SIZE] = "Hello";
      LString *hello = localString(buff, SIZE);
      ...
      lstringchcat(hello, " World !");
    }  <--- automatic deallocation at the end of the scope
 
   Warning: The following does not work (because localString does  
            not allocate memory):
    LString *hello = localString("Hello World", SIZE);  

In my opinion it must be:

      #define SIZE 40   <--- the LString can never grow longer than 39 chars
      static char buff[SIZE] = "Hello";
      LString hello = localString(buff, SIZE);
      ...
      lstringchcat(&hello, " World !");
    }  <--- automatic deallocation at the end of the scope
 
   Warning: The following does not work (because localString does  
            not allocate memory):
    LString hello = localString("Hello World", SIZE); 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions