Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vpkmq0$21php$1@dont-email.me>
Deutsch   English   Français   Italiano  
<vpkmq0$21php$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Ar Rakin <rakinar2@onesoftnet.eu.org>
Newsgroups: comp.lang.c
Subject: Which code style do you prefer the most?
Date: Tue, 25 Feb 2025 21:15:12 +0600
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <vpkmq0$21php$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 25 Feb 2025 16:15:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="f56c6d46c610cdb54bbc2d41e3b735c1";
	logging-data="2156089"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18jgq1Gie76O3XGWCXCaXdTOb47LFppOks="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Z3Oq1TsaDOWfCDG6hjCjAnCpi0A=
Content-Language: en-US
Bytes: 2833

Hello there,

I've been writing C code for a long time, in different styles, but 
always wanted to know which code style most people prefer. This is all 
about that question. Which one of the following do you prefer the most?

1. GNU Style

---------

#include <stddef.h>
#include <stdbool.h>

#include "malloc_internals.h"

struct malloc_chunk
{
   struct malloc_chunk *next; /* The next chunk. */
   struct malloc_chunk *prev; /* The previous chunk. */
   bool is_free;              /* Whether this chunk is usable. */
   size_t size;               /* The size of this chunk. */
};

static inline void *
get_chunk_ptr (struct malloc_chunk *chunk)
{
   return (void *) (chunk + 1);
}

void *
malloc (size_t size)
{
   struct malloc_chunk *chunk = mm_find_chunk (size, MM_CHUNK_FREE);

   if (chunk)
     return get_chunk_ptr (chunk);

   chunk = mm_alloc_chunk (size);

   if (!chunk)
     return NULL;

   return get_chunk_ptr (chunk);
}

---------


2. Linux Style

---------

#include <stddef.h>
#include <stdbool.h>

#include "malloc_internals.h"

struct malloc_chunk {
         struct malloc_chunk *next;   /* The next chunk. */
         struct malloc_chunk *prev;   /* The previous chunk. */
         bool                is_free; /* Whether this chunk is usable. */
         size_t              size;    /* The size of this chunk. */
};

static inline void *get_chunk_ptr(struct malloc_chunk *chunk)
{
         return (void *) (chunk + 1);
}

void *malloc(size_t size)
{
         struct malloc_chunk *chunk = mm_find_chunk(size, MM_CHUNK_FREE);

         if (chunk)
                 return get_chunk_ptr(chunk);

         chunk = mm_alloc_chunk(size);

         if (!chunk)
                 return NULL;

         return get_chunk_ptr(chunk);
}

---------

3. Other Styles?

Please show an example!

Thank you.