Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:21:09+00:00 2026-06-15T18:21:09+00:00

Im trying to use this but when I run it with valgrind I have

  • 0

Im trying to use this but when I run it with valgrind I have some memory problems.

For expample

char *serialize_file(t_file_package *pack) {

     char *payLoad = malloc(numDigits(pack->file_desc)+numDigits(pack->priority)+strlen(pack->code)+2);
     sprintf(payLoad, "%d#%d#%s", (uint32_t)pack->file_desc,(int16_t)pack->priority, pack->code);
     char *pack = malloc(numDigits(PROCESS) + numDigits((int64_t)strlen(payLoad)) + strlen(payLoad)+2);

     sprintf(pack, "%d#%d#%s",PROCESS, strlen(payLoad), payLoad);
     free(payLoad);
     return pack;
}

I know of the existence of asprintf but I downt know why i cant use it in my GNU ANSI C project… My eclipse says that that function is not recognized

Thank you in advanced!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:21:10+00:00Added an answer on June 15, 2026 at 6:21 pm

    you aren’t allowing space for the null character at the end of the string – the string needs space for the digits in “file_desc”, the digits in “priority”, the characters in “code”, the two “#” characters and the terminal null character.

    The same problem exists with the second call to malloc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run this code but I get this error anytime I use
I'm trying to use this coding but its not processing, and its not outputing
I'm trying to use this library (which looks very nice) but I'm having difficulty
I'm trying to use this to create a splash screen, but I only get
I am trying to use this code in my QT app QMap<QString,QMap> but there
I'm trying to to use this class http://robbyonrails.com/articles/2005/05/11/parsing-a-rss-feed but am not sure where to
I am trying to use SpinLock, but even this most basic code in a
Im trying to use Date Formatters (NSDateFormatter), but I keep getting this error: Program
I'm trying to use this tool https://swingexplorer.dev.java.net/ to find some information out about an
I'm trying to use this Ubuntu Upstart script to set up Play to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.