-
Notifications
You must be signed in to change notification settings - Fork 4
Cnode improvements and fixes #8
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
Open
rinpatch
wants to merge
10
commits into
Overbryd:master
Choose a base branch
from
rinpatch:cnode-improvements-and-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3a5f773
Cnode improvements and fixes
3b06c47
Cnode: Make null pointer check for the comment string shorter and fix
09e0460
Cnode: Do not omit the left part of ?: because -Wpedantic complains
862536b
Cnode: Move result assignment out of tag atom check because it's the
11e0b0f
Cnode: Use a VLA tag namespace
b2b93c3
Cnode: Shorten next node picking
6e70eb6
Cnode: use sizeof() for snprintf() buffer limit
395d292
Cnode: replace strpcpy with strncpy
71079bd
Cnode: use strncpy for copying tag name to the tag string
c03fa4f
Cnode: use strncpy for concatenating hostnames
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #ifndef TSTACK_H | ||
| #define TSTACK_H | ||
|
|
||
| #include "ei.h" | ||
| #define GROW_BY 30 | ||
|
|
||
| typedef struct { | ||
| ETERM* *data; | ||
| size_t used; | ||
| size_t size; | ||
| } tstack; | ||
|
|
||
| void tstack_init(tstack *stack, size_t initial_size) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move the implementation of each function to |
||
| stack->data = (ETERM **) malloc(initial_size * sizeof(ETERM*)); | ||
| stack->used = 0; | ||
| stack->size = initial_size; | ||
| } | ||
|
|
||
| void tstack_free(tstack *stack) { | ||
| free(stack->data); | ||
| } | ||
|
|
||
| void tstack_resize(tstack *stack, size_t new_size) { | ||
| stack->data = (ETERM **)realloc(stack->data, new_size * sizeof(ETERM*)); | ||
| stack->size = new_size; | ||
| } | ||
|
|
||
| void tstack_push(tstack *stack, ETERM* element) { | ||
| if(stack->used == stack->size) { | ||
| tstack_resize(stack, stack->size + GROW_BY); | ||
| } | ||
| stack->data[stack->used++] = element; | ||
| } | ||
|
|
||
| ETERM* tstack_pop(tstack *stack) { | ||
| return stack->data[--(stack->used)]; | ||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| defmodule Myhtmlex.SafeTest do | ||
| use MyhtmlexSharedTests, module: Myhtmlex.Safe | ||
|
|
||
| test "doesn't segfault when <!----> is encountered" do | ||
| assert {"html", _attrs, _children} = Myhtmlex.decode("<div> <!----> </div>") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important fix, thank you. |
||
| end | ||
| end | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through this change with a fellow programmer of mine, and now after following through and understanding, I think its wayyy smarter to use a stack here, than my previous implementation.
Makes perfect sense and should be much safer.