atoi() is able to translate a string of a number into an integer number. There are lots of tech to do, and here is showing some examples.

int my_atoi(char *p) {
  int k = 0;
  while (*p) {
    k = k*10 + (*p) - '0';
    p++;
  }
  return k;
}

10 times can be switched to bit-wise shift since bit-wise will use smaller instruction set which enables to reduce transistor in a system. Following shows of it.

int my_atoi(char *p) {
 int k = 0;
 while (*p) {
 k = (k<<3)+(k<<1)+(*p)-'0';
 p++;
 }
 return k;
}
 
c-x c-c

Or

M-x save-buffers-kill-emacs
 

Here is an information not to use cache in linux while reading the kernel newbie mailing list.

Hi!
On 19:29 Fri 04 Dec     , Lal wrote:
> Dear list members,
>
> I have a question about Linux page cache. I create a 10MB file using
> following application code:
>
> int fd=open(“foo.txt”, O_CREAT|O_RDWR|O_SYNC);
> char* content=(char *)malloc(1024*1024*10);
> write(fd, content, 1024*1024*10);
> free(content); close(fd);
>
> Immediately before and after this code execution, command “free -m”
> shows free memory decreased by 10M and cache incresed by 10M.
>
> If I delete foo.txt, then free memory increases by 10M and cache
> decreases by 10M.
>
> My question is why the cache is growing even after O_SYNC flag? Even
> fsync does not help. But deleting file freeing the cache.

O_SYNC does not mean “do not cache”. It means “make sure the data is written
to disk. The data is kept in memory even after writing to speed up subsequent
reads. If you do not want this, you can pass the O_DICECT flag. But be aware
that using this can easily slow you down.
Either way, if you want to write zeros to the file, make sure the buffer is
initialised after malloc, e.g. via memset or bzero. If you only want to
allocate a file with zeros, you can also consider using fallocate or sparse
files.

-Michi

 

Mediawiki uses ImageMagick Utility for resized thumbnail image. You can use it as

$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

in your LocalSettings.php.

There are two reasons why ImageMagick is beneficial.

  1. It reduces loading time for image file as it stores thumbnail image separately.
  2. It gives higher quality than GD library.

However, you may encounter following error when shell memory is not allocated big enough.

Error creating thumbnail:
libgomp: Thread creation failed: Cannot allocate memory

It is due to small shell memory allocation which is handled by Mediawiki. In this case, you can simply add following in LocalSettings.php

$wgMaxShellMemory = 524288;

524288 means 512K. You can specify it as you desire. 1

 

December 2009
S M T W T F S
« Nov   Feb »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Follow Me

© 2011 Bread & Cup Suffusion theme by Sayontan Sinha