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

Add include guards and memory allocation wrappers that can be overwri… #11

Merged
merged 3 commits into from
May 11, 2022

Conversation

mingodad
Copy link
Contributor

…tten by end users

@mingodad
Copy link
Contributor Author

Doing this I realized that we are very confident that memory allocation will never fail !

@ChrisHixon
Copy link
Owner

This is incomplete in the bootstrap dir:

% grep malloc peg_cbyte.c    
    res = (unsigned char *)malloc(len + 1);
    Node *self = (Node *)malloc(sizeof(Node));
    Parser *self = (Parser *)malloc(sizeof(Parser));
    ByteCode *self = (ByteCode *)malloc(sizeof(ByteCode));

Fails to make in examples after bootstrap:

# bootstrap:
[~/Projects/GitHub/chpeg/bootstrap]% ./generate_src_files

# make in examples:
[~/Projects/GitHub/chpeg/examples]% make clean; make
rm -rf obj
rm -rf chpeg
rm peg_parse_file
rm: cannot remove 'peg_parse_file': No such file or directory
make: [Makefile:50: clean] Error 1 (ignored)
mkdir obj
mkdir chpeg
gcc -c -Wall -std=c99 -O3 ../src/peg_cbyte_parser.c -o chpeg/peg_cbyte_parser.o
In file included from ../src/peg_cbyte_parser.c:4:
../src/peg_cbyte_parser.h:222:2: error: #endif without #if
  222 | #endif //PEG_CBYTE_PARSER_H
      |  ^~~~~
make: *** [Makefile:41: chpeg/peg_cbyte_parser.o] Error 1

@mingodad
Copy link
Contributor Author

My fault I forgot to add the open include guard on the bootstrap template, I think that's fixed now.

@ChrisHixon ChrisHixon merged commit c7587ea into ChrisHixon:master May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants