Skip to content

Commit

Permalink
Fix some errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-attack committed Feb 15, 2025
1 parent 018e070 commit ab3c7be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Parameter.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <pubsub/Parameter.h>

//#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>

#include <pubsub/Node.h>
Expand Down
5 changes: 3 additions & 2 deletions tools/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <map>

#include <cstdint>
#include <vector>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -587,7 +588,7 @@ std::string generate(const char* definition, const char* name)
}

output += " out->" + fields[i].name + "_length = num_" + fields[i].name + ";\n";
output += " out->" + fields[i].name + " = (char**)malloc(sizeof(char*)*num_" + fields[i].name + ");\n";
output += " out->" + fields[i].name + " = (char**)allocator->alloc(sizeof(char*)*num_" + fields[i].name + ", allocator->context);\n";

// allocate the array
// need to do it!
Expand All @@ -596,7 +597,7 @@ std::string generate(const char* definition, const char* name)
output += " int len = *(uint32_t*)p;\n";
output += " p += 4;\n";// add size of length
// now read and allocate each string
output += " out->" + fields[i].name + "[i] = (char*)malloc(len);\n";
output += " out->" + fields[i].name + "[i] = (char*)allocator->alloc(len, allocator->context);\n";
output += " memcpy(out->" + fields[i].name + "[i], p, len);\n";
output += " p += len;\n";
output += " }\n";
Expand Down

0 comments on commit ab3c7be

Please sign in to comment.