GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add malloc.h into StandardCLibrary.h. by ahuo-dev · Pull Request #1835 · cpputest/cpputest

Conversation

@ahuo-dev

@ahuo-dev ahuo-dev commented Jan 2, 2025

Copy link
Copy Markdown

Add malloc.h into StandardCLibrary.h. Some C code include malloc.h for malloc func.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ahuo-dev
add malloc.h into StandardCLibrary.h. Some C code include malloc.h f…
2775e3d
…or malloc func.
@thetic

thetic commented Jan 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Per the standard, malloc is declared in stdlib.h1 which is already included.

Footnotes

  1. https://en.cppreference.com/w/c/memory/malloc ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@basvodde

basvodde commented Jan 2, 2025

Copy link
Copy Markdown
Member

@ahuo-dev Could you share what environment you were trying to solve what problem, then we can look at whether this is the best fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahuo-dev

ahuo-dev commented Jan 2, 2025

Copy link
Copy Markdown
Author

Per the standard, malloc is declared in stdlib.h1 which is already included.

Footnotes

  1. https://en.cppreference.com/w/c/memory/malloc ↩

@ahuo-dev Could you share what environment you were trying to solve what problem, then we can look at whether this is the best fix.

@basvodde My project use amazonaws kinesis video stream code. I have a compile error when enable cpputest memory leak check . and I found amazonaws kinesis video stream code use malloc header with malloc.h. see this code line 523 at https://github.com/awslabs/amazon-kinesis-video-streams-pic/blob/master/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@basvodde

basvodde commented Jan 9, 2025

Copy link
Copy Markdown
Member

Ok, but the include of #malloc.h in the CommonDef.h shouldn't need to trigger you to include it in the SatndardCLibrary.h, right?

Could you share what the compile error is that you are getting?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahuo-dev

ahuo-dev commented Jan 14, 2025

Copy link
Copy Markdown
Author

Ok, but the include of #malloc.h in the CommonDef.h shouldn't need to trigger you to include it in the SatndardCLibrary.h, right?

Could you share what the compile error is that you are getting?

Compile error message :
"nclude/CppUTest/MemoryLeakDetectorMallocMacros.h:36:47: error: expected declaration specifiers or ‘...’ before string constant
36 | #define malloc(a) cpputest_malloc_location(a, FILE, LINE)"

and run command "gcc -E " to expand all macro. I see malloc function prototype expand to cpputest_malloc_location, like this :
extern void *

38 "/usr/include/malloc.h"

        cpputest_malloc_location(

38 "/usr/include/malloc.h" 3 4

        size_t __size

38 "/usr/include/malloc.h"

        , "/usr/include/malloc.h", 38)

38 "/usr/include/malloc.h" 3 4

                               __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__))
 __attribute__ ((__alloc_size__ (1))) ;

Normally it should be like this:
extern void *malloc (size_t __size) __THROW attribute_malloc
attribute_alloc_size ((1)) __wur;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ahuo-dev @thetic @basvodde
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.