i wrote some code to format c code for me
it turns this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static heap_t *_heap_create(int s, long *f)
{
heap_t *h;
h = malloc(sizeof(heap_t));
h->h = malloc(sizeof(int)*s);
h->s = h->cs = s;
h->n = 0;
h->f = f;
return h;
}
static void _heap_destroy(heap_t *heap)
{
free(heap->h);
free(heap);
}
int main()
{
huffcode_t **r;
int i;
char strbit[MAXBITSPERCODE];
const char *p;
long freqs[BYTES];
memset(freqs, 0, sizeof freqs);
p = test;
while(*p != '\0') freqs[*p++]++;
r = create_huffman_codes(freqs);
for(i=0; i < BYTES; i++) {
if ( r[i] != NULL ) {
inttobits(r[i]->code, r[i]->nbits, strbit);
printf("%c (%d) %s\n", i, r[i]->code, strbit);
}
}
free_huffman_codes(r);
return 0;
}
into this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static heap_t *_heap_create(int s, long *f) {
heap_t *h ;
h = malloc(sizeof(heap_t)) ;
h->h = malloc(sizeof(int)*s) ;
h->s = h->cs = s ;
h->n = 0 ;
h->f = f ;
return h ;}
static void _heap_destroy(heap_t *heap) {
free(heap->h) ;
free(heap) ;}
int main() {
huffcode_t **r ;
int i ;
char strbit[MAXBITSPERCODE] ;
const char *p ;
long freqs[BYTES] ;
memset(freqs, 0, sizeof freqs) ;
p = test ;
while(*p != '\0') freqs[*p++]++ ;
r = create_huffman_codes(freqs) ;
for(i=0; i < BYTES; i++) {
if ( r[i] != NULL ) {
inttobits(r[i]->code, r[i]->nbits, strbit) ;
printf("%c (%d) %s\n", i, r[i]->code, strbit) ;}}
free_huffman_codes(r) ;
return 0 ;}