Skip to content

Commit

Permalink
convert comment_data to a value from a pointer (#16663)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored Jul 5, 2024
1 parent 374b357 commit 99fd9e2
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions compiler/src/dmd/backend/elfobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct ElfObj

IDXSEC secidx_note; // Final table index for note data

OutBuffer* comment_data; // Comment data for compiler version
OutBuffer comment_data; // Comment data for compiler version

int seg_tlsseg = UNKNOWN;
int seg_tlsseg_bss = UNKNOWN;
Expand Down Expand Up @@ -609,7 +609,7 @@ Obj ElfObj_init(OutBuffer *objbuf, const(char)* filename, const(char)* csegname)

elfobj.note_data.reset();
elfobj.secidx_note = 0;
elfobj.comment_data = null;
elfobj.comment_data.reset();
elfobj.seg_tlsseg = UNKNOWN;
elfobj.seg_tlsseg_bss = UNKNOWN;
elfobj.GOTsym = null;
Expand Down Expand Up @@ -724,8 +724,7 @@ Obj ElfObj_init(OutBuffer *objbuf, const(char)* filename, const(char)* csegname)

elfobj.note_data.reset();

if (elfobj.comment_data)
elfobj.comment_data.reset();
elfobj.comment_data.reset();

elfobj.symbol_idx = 0;
elfobj.local_cnt = 0;
Expand Down Expand Up @@ -1066,7 +1065,7 @@ void ElfObj_term(const(char)[] objfilename)
foffset += sechdr.sh_size;
}

if (elfobj.comment_data)
if (elfobj.comment_data.length())
{
sechdr = &elfobj.SecHdrTab[SHN_COM]; // Comments
sechdr.sh_size = cast(uint)elfobj.comment_data.length();
Expand Down Expand Up @@ -1418,14 +1417,8 @@ void ElfObj_exestr(const(char)* p)
void ElfObj_user(const(char)* p)
{
//printf("ElfObj_user(char *%s)\n",p);
if (!elfobj.comment_data)
{
elfobj.comment_data = cast(OutBuffer*) calloc(1, OutBuffer.sizeof);
if (!elfobj.comment_data)
err_nomem();
if (elfobj.comment_data.length() == 0)
elfobj.comment_data.writeByte(0);
}

elfobj.comment_data.writestring(p);
elfobj.comment_data.writeByte(0);
}
Expand Down

0 comments on commit 99fd9e2

Please sign in to comment.