Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: config typo and small memory fix in extnotes.c #201

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

ANUKOOL324
Copy link
Contributor

@ANUKOOL324 ANUKOOL324 commented Oct 3, 2024

Fix Typos and Enhance Memory Management in tailwind.config.js and extnotes.c

  1. Typographical Error:

    • File: tailwind.config.js

    • Issue: a type error

                   mono: ['"Ubunto Mono"', ...mono]
      
    • Solution:

                    mono: ['"Ubuntu Mono"', ...mono]
      
    • It ensures proper recognition of the font, improving the overall aesthetic consistency of the application.

  2. Memory Management Improvement:

    • File: extnotes.c
    • Issue: The original code did not safely handle the result of realloc. If realloc failed, it could lead to memory leaks since
      the original pointer would be lost.
    • Solution: Introduced a temporary pointer (temp) to hold the result of realloc. This ensures that if realloc fails, the
      original buffer remains intact and can be freed properly.

    The updated code now checks the allocation:

       if (packetSize > bufSz)
       {
           unsigned char *temp = realloc(buf, packetSize); // Use a temporary pointer
           if (!temp)
           {              // Check if memory allocation failed
               free(buf); // Free the existing buffer to avoid a memory leak
               break;
           }
           buf = temp; // Only assign buf if realloc was successful
           bufSz = packetSize;
       }; 
    

These changes aim to enhance the reliability and performance of the application by correcting minor bugs and improving memory safety.

Hey @Snazzah assign this under the [hacktoberfest2024) :) !!

…notes.c

1. **Typographical Error**:
   - **File**: tailwind.config.js
   - **Issue**: The configuration contained a typo related to Fontfaimly mono: ['"Ubunto Mono"', ...mono]
   - **Solution**: Corrected the typo -> mono: ['"Ubuntu Mono"', ...mono]. It ensure proper recognition of the font, improving the overall aesthetic consistency of the application.

2. **Memory Management Improvement**:
   - **File**: extnotes.c
   - **Issue**: The original code did not safely handle the result of `realloc`. If `realloc` failed, it could lead to memory leaks since the original pointer would be lost.
   - **Solution**: Introduced a temporary pointer (`temp`) to hold the result of `realloc`. This ensures that if `realloc` fails, the original buffer remains intact and can be freed properly.

   The updated code now checks the allocation:
     ```c
     unsigned char *temp = realloc(buf, packetSize);
     if (!temp) {
         free(buf);
         break;
     }
     buf = temp;
     bufSz = packetSize;
     ```

These changes aim to enhance the reliability and performance of the application by correcting minor bugs and improving memory safety. Thorough testing should be conducted to ensure these fixes integrate well with existing functionalities.
@ANUKOOL324 ANUKOOL324 requested a review from Snazzah as a code owner October 3, 2024 20:36
@Snazzah Snazzah added hacktoberfest-accepted enhancement New feature or request labels Oct 3, 2024
@Snazzah
Copy link
Member

Snazzah commented Oct 3, 2024

Other than the styling on the C code, I'm okay with this

@Snazzah Snazzah changed the title Fix Typos and Enhance Memory Management in tailwind.config.js and extnotes.c fix: config typo and small memory fix in extnotes.c Oct 3, 2024
@Snazzah Snazzah merged commit 81ba0f4 into CraigChat:master Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants