---
title: "MALLOC Problem"
url: "https://maker.wiznet.io/forum/11971"
markdown_url: "https://maker.wiznet.io/forum/11971/md"
type: "Forum topic"
category: "MCU & Boards"
author: "8milan8"
created: "2016-10-14T14:10:35+09:00"
last_activity: "2017-05-04T08:40:09+09:00"
language: "en"
views: 591
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# MALLOC Problem

## Question

Asked by 8milan8 on 2016-10-14 in MCU & Boards.

Hello,

I wrote the simple program below. But always return ERROR. What am I doing wrong? Thanks! (I’m using WizWiki-7500P with lastes sources from github)

```
#include <stdio.h>
#include <stdlib.h>
#include "W7500x_uart.h"

int main()
{   
	  SystemInit();
    SysTick_Config((GetSystemClock()/1000));
    
  	S_UART_Init(9600);
    
    printf("System frequency: %d Hz\r\n", GetSystemClock());

    uint8_t * cnt = malloc(sizeof(uint8_t));
    if (NULL == cnt) {
        printf("ERROR");
    }
    else {
        printf("OK");
    }
    
    while(1) {     
    } 
}
```

## Replies

### Reply 1 by becky, 2017-04-11

Hello,

I apologize for the delay.
I modified the following and confirmed that it works well.
I moved the malloc declaration to the front and changed the uart baudrate to 115200.

Thankyou. ![:smiley:](https://emoji.discourse-cdn.com/twitter/smiley.png?v=12)

```
	int main() {   

	uint8_t *cnt=malloc(sizeof(uint8_t));
	SystemInit();
	SysTick_Config((GetSystemClock()/1000));
    
	S_UART_Init(115200);
    
	printf("System frequency: %d Hz\r\n", 	GetSystemClock());
	
	if (NULL == cnt) {
    	    printf("ERROR");
    	}
    	else {
       	 printf("OK");
    	}
    	
   	 while(1) {     
    	} 
    }
```

---

Source: https://maker.wiznet.io/forum/11971
