#include <stdio.h>
#include <stdlib.h>
void func(unsigned char *buf)
{
int size = 10;
printf("%p\n", buf);
buf = (char *)malloc(size);
printf("%p\n", buf);
for (int i = 0; i < size; i++)
{
buf[i] = 'a' + i;
}
}
void print(unsigned char *buf, int size)
{
printf("%p\n", buf);
}
void func2(unsigned char **buf, int size)
{
*buf = (unsigned char*)malloc(size);
for (int i = 0; i < size; i++)
{
(*buf)[i] = 'a' + i;
}
}
void func_free(unsigned char **buf)
{
if (NULL != *buf)
{
free(*buf);
*buf = NULL;
}
}
void func3(unsigned int *puiNumList, int size)
{
if ((NULL == puiNumList) ||
(0 == size))
{
return;
}
for (int i = 0; i < size; i++)
{
printf("num: %d\n", puiNumList[i]);
}
}
void func4(unsigned char *buf, int size)
{
buf = (unsigned char*)malloc(size);
if (NULL == buf)
{
printf("malloc error\n");
}
for (int i = 0; i < size; i++)
{
buf[i] = 'a' + i;
}
}
int main () {
char* buf;
func(buf);
print(buf, 10);
return 0;
}