我想在像这样的 makefile 中运行脚本
all: a b
a:
cd ~/trials; \
. ./sx.sh
b:
echo $(bn)
Run Code Online (Sandbox Code Playgroud)
sx.sh 这样做
export bn=1
Run Code Online (Sandbox Code Playgroud)
发出 make 命令时,我在终端中看不到该变量。我的目标是在针对这些脚本特定设置编译我的项目之前运行脚本。
我正在阅读和试验本书中的指针,
http://shop.oreilly.com/product/0636920028000.do
在本书的第6章中,在避免malloc/free Overhead标题下,作者建议如何在进行大量结构内存分配/解除分配时避免malloc/free开销.
以下是他编写函数的方式,
#define LIST_SIZE 10
Person *list[LIST_SIZE];
void initializeList()
{
int i=0;
for(i=0; i<LIST_SIZE; i++)
{
list[i] = NULL;
}
}
Person *getPerson()
{
int i=0;
for(i=0; i<LIST_SIZE; i++)
{
if(list[i] != NULL)
{
Person *ptr = list[i];
list[i] = NULL;
return ptr;
}
}
Person *person = (Person*)malloc(sizeof(Person));
return person;
}
void deallocatePerson(Person *person)
{
free(person->firstName);
free(person->lastName);
free(person->title);
}
Person *returnPerson(Person *person)
{
int i=0;
for(i=0; i<LIST_SIZE; i++)
{
if(list[i] == NULL)
{
list[i] …Run Code Online (Sandbox Code Playgroud)