-
Couldn't load subscription status.
- Fork 7
Code improvements #228
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
Code improvements #228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,8 +136,11 @@ extern void reent_init(struct _clib4 *__clib4, BOOL fallback); | |
| #undef DebugPrintF | ||
| #define bug IExec->DebugPrintF | ||
| #else | ||
| # ifdef D | ||
| # undef D | ||
| # endif // D | ||
| #define D(x) ; | ||
|
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. The compiler was complaining the the D is redefined |
||
| #endif | ||
| #endif // DEBUG | ||
|
|
||
| int32 | ||
| _start(STRPTR args, int32 arglen, struct ExecBase *sysbase) { | ||
|
|
@@ -204,8 +207,6 @@ struct Clib4Library *libOpen(struct LibraryManagerInterface *Self, uint32 versio | |
| struct Clib4Resource *res = (APTR) IExec->OpenResource(RESOURCE_NAME); | ||
| if (res) { | ||
| struct Clib4Node c2n; | ||
| char varbuf[8] = {0}; | ||
| char uuid[UUID4_LEN + 1] = {0}; | ||
|
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. Those were not used anywhere |
||
| uint32 pid = IDOS->GetPID(0, GPID_PROCESS); | ||
| uint32 ppid = IDOS->GetPID(0, GPID_PARENT); | ||
|
|
||
|
|
@@ -436,11 +437,11 @@ clib4ProcessCompare(const void *a, const void *b, void *udata) { | |
| struct Clib4Library *libInit(struct Clib4Library *libBase, BPTR seglist, struct ExecIFace *const iexec) { | ||
| libBase->libNode.lib_Node.ln_Type = NT_LIBRARY; | ||
| libBase->libNode.lib_Node.ln_Pri = LIBPRI; | ||
| libBase->libNode.lib_Node.ln_Name = LIBNAME; | ||
| libBase->libNode.lib_Node.ln_Name = (char *)LIBNAME; | ||
| libBase->libNode.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED; | ||
| libBase->libNode.lib_Version = VERSION; | ||
| libBase->libNode.lib_Revision = REVISION; | ||
| libBase->libNode.lib_IdString = VSTRING; | ||
| libBase->libNode.lib_IdString = (char *)VSTRING; | ||
|
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. The compiler was complaining for losing the const character |
||
| libBase->SegList = seglist; | ||
|
|
||
| SysBase = (struct ExecBase *) iexec->Data.LibBase; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,8 @@ inet_pton(int af, const char *src, void *dst) { | |
| static int | ||
| inet_pton4(const char *src, unsigned char *dst) { | ||
| int saw_digit, octets, ch; | ||
| unsigned char tmp[NS_INADDRSZ], *tp; | ||
| unsigned char tmp[NS_INADDRSZ] = {0}; | ||
| unsigned char *tp; | ||
|
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. The |
||
|
|
||
| saw_digit = 0; | ||
| octets = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ vdprintf(int fd, const char *format, va_list ap) { | |
| } | ||
| ret2 = vsnprintf(ptr, ret, format, ap); | ||
| if (ret2 < 0) { | ||
| free(ptr); | ||
|
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. memory leak |
||
| return EOF; | ||
| } | ||
| ret = ret2; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,24 +68,28 @@ pntz(size_t p[2]) { | |
|
|
||
| static void | ||
| cycle(size_t width, unsigned char *ar[], int n) { | ||
| unsigned char tmp[256]; | ||
| size_t tmp_size = 256; | ||
| unsigned char *tmp = malloc(tmp_size); | ||
| size_t l; | ||
| int i; | ||
|
|
||
| if (n < 2) { | ||
| free(tmp); | ||
| return; | ||
| } | ||
|
|
||
| ar[n] = tmp; | ||
|
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. With these changes the following critical error is fixed, referring to this line.
|
||
| while (width) { | ||
| l = sizeof(tmp) < width ? sizeof(tmp) : width; | ||
| l = tmp_size < width ? tmp_size : width; | ||
| memcpy(ar[n], ar[0], l); | ||
| for (i = 0; i < n; i++) { | ||
| memcpy(ar[i], ar[i + 1], l); | ||
| ar[i] += l; | ||
| } | ||
| width -= l; | ||
| } | ||
|
|
||
| free(tmp); | ||
| } | ||
|
|
||
| /* shl() and shr() need n > 0 */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,6 +296,7 @@ tgetent(char *bp, const char *name) { | |
| bp = (char *) malloc(malloc_size); | ||
| if (bp == NULL) { | ||
| __set_errno(ENOMEM); | ||
| free(buf.beg); | ||
|
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. memory leak |
||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ char *dns_lookup(char *addr_host, struct sockaddr_in *addr_con) { | |
| host_entity = gethostbyname(addr_host); | ||
| if (host_entity == NULL) { | ||
| // No ip found for hostname | ||
| free(ip); | ||
|
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. memory leak |
||
| return NULL; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,12 @@ int main () { | |
| len = mblen( pmb, MB_CUR_MAX ); | ||
| printf( "Length in bytes of multibyte character %x: %u\n", pmb, len ); | ||
|
|
||
| free(pmb); | ||
| pmb = NULL; | ||
|
|
||
| len = mblen( pmb, MB_CUR_MAX ); | ||
| printf( "Length in bytes of multibyte character %x: %u\n", pmb, len ); | ||
|
|
||
|
|
||
| free(pwcs); | ||
|
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. memory leaks fixes |
||
| return(0); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,5 +21,7 @@ int main() { | |
| printf("Hex value of first wide character %#.4x\n\n", pwcs); | ||
| free(pwcs); | ||
| } | ||
|
|
||
| free(pmb); | ||
|
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. memory leak fix |
||
| return (0); | ||
| } | ||
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.
The
text_startwas not initialised and whenif (low_pc == 0 && high_pc == 0) {was false this had no initial value atp->text_start = text_start;on line 175